/* Add authentication creditials to a request */ char *http_auth_request_header(http_auth_session *sess) { if (sess->will_handle) { switch(sess->scheme) { case http_auth_scheme_basic: return request_basic(sess); break; case http_auth_scheme_digest: return request_digest(sess); break; default: break; } } return NULL; }
static void ah_pre_send(ne_request *r, void *cookie, ne_buffer *request) { auth_session *sess = cookie; struct auth_request *req = ne_get_request_private(r, sess->spec->id); if (!sess->can_handle || !req) { NE_DEBUG(NE_DBG_HTTPAUTH, "Not handling session.\n"); } else { char *value; NE_DEBUG(NE_DBG_HTTPAUTH, "Handling auth session.\n"); req->will_handle = 1; switch(sess->scheme) { case auth_scheme_basic: value = request_basic(sess); break; case auth_scheme_digest: value = request_digest(sess, req); break; #ifdef HAVE_GSSAPI case auth_scheme_gssapi: value = request_gssapi(sess); break; #endif #ifdef HAVE_SSPI case auth_scheme_sspi_negotiate: case auth_scheme_sspi_ntlm: value = request_sspi(sess); break; #endif default: value = NULL; break; } if (value != NULL) { ne_buffer_concat(request, sess->spec->req_hdr, ": ", value, NULL); ne_free(value); } } }