MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / answer_to_connection

Function answer_to_connection

modules/httpd/httpd_proc.c:448–787  ·  view source on GitHub ↗

0x00097001 changed the returned result */

Source from the content-addressed store, hash-verified

446
447/* 0x00097001 changed the returned result */
448MHD_RET answer_to_connection (void *cls, struct MHD_Connection *connection,
449 const char *url, const char *method,
450 const char *version, const char *upload_data,
451 size_t *upload_data_size, void **con_cls)
452{
453 str page = {NULL, 0};
454 struct MHD_Response *response;
455 int ret;
456 void *async_data = NULL;
457 struct httpd_cb *cb = NULL;
458 const char *normalised_url;
459 struct post_request *pr;
460 str_str_t *kv;
461 char *p;
462 int ret_code = MHD_HTTP_OK;
463 str saved_body = STR_NULL;
464
465#if ( MHD_VERSION >= 0x000092800 )
466 int sv_sockfd;
467 socklen_t addrlen=sizeof(httpd_server_info);
468#endif
469 union sockaddr_union* cl_socket;
470
471 LM_DBG("START *** cls=%p, connection=%p, url=%s, method=%s, "
472 "versio=%s, upload_data[%zu]=%p, *con_cls=%p\n",
473 cls, connection, url, method, version,
474 *upload_data_size, upload_data, *con_cls);
475
476 pr = *con_cls;
477 if(pr == NULL){
478 /* first call for this request -- check auth before allocating */
479 if (auth_username.s) {
480 char *user = NULL;
481 char *pass = NULL;
482
483 user = MHD_basic_auth_get_username_password(connection,
484 &pass);
485 if (!user || !pass ||
486 strlen(user) != auth_username.len ||
487 strlen(pass) != auth_password.len ||
488 memcmp(user, auth_username.s,
489 auth_username.len) != 0 ||
490 memcmp(pass, auth_password.s,
491 auth_password.len) != 0) {
492 LM_WARN("rejected unauthenticated HTTP request "
493 "for %s\n", url);
494 response = MHD_create_response_from_buffer(
495 MI_HTTP_UNAUTH.len,
496 (void *)MI_HTTP_UNAUTH.s,
497 MHD_RESPMEM_PERSISTENT);
498 ret = MHD_queue_basic_auth_fail_response(
499 connection, auth_realm.s, response);
500 MHD_destroy_response(response);
501#if MHD_VERSION >= 0x00093800
502 if (user) MHD_free(user);
503 if (pass) MHD_free(pass);
504#else
505 if (user) free(user);

Callers

nothing calls this directly

Calls 8

profiling_proc_startFunction · 0.85
slinkedl_initFunction · 0.85
get_httpd_cbFunction · 0.85
slinkedl_traverseFunction · 0.85
ss_merge256Function · 0.85
slinkedl_list_destroyFunction · 0.85
slinkedl_appendFunction · 0.85
profiling_proc_endFunction · 0.85

Tested by

no test coverage detected