Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HTTP fragmentation #3540

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions modules/httpd/httpd_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ int httpd_get_val(void *e_data, void *data, void *r_data)
return 0;
}

static char httpd_full_buff[16384];
vladpaiu marked this conversation as resolved.
Show resolved Hide resolved
static int httpd_full_buff_pos=0;
int httpd_merge_data(void *e_data, void *data, void *r_data)
{
str_str_t *kv = (str_str_t*)e_data;
if (kv==NULL) {
LM_ERR("null data\n");
} else {
LM_DBG("data=[%p] [%p][%p] [%.*s]->[%.*s]\n",
kv, kv->key.s, kv->val.s,
kv->key.len, kv->key.s,
kv->val.len, kv->val.s);
memcpy(httpd_full_buff+httpd_full_buff_pos,kv->val.s,kv->val.len);
vladpaiu marked this conversation as resolved.
Show resolved Hide resolved
httpd_full_buff_pos+=kv->val.len;
}
return 0;
}

/**
* Function to print data stored in slinkedl_list list elemnts.
* For debugging purposes only.
Expand Down Expand Up @@ -498,9 +516,12 @@ MHD_RET answer_to_connection (void *cls, struct MHD_Connection *connection,
if (cb) {
normalised_url = &url[cb->http_root->len+1];
LM_DBG("normalised_url=[%s]\n", normalised_url);
kv = slinkedl_peek(pr->p_list);
if (kv)
saved_body = ((str_str_t *)kv)->val;
httpd_full_buff_pos=0;
slinkedl_traverse(pr->p_list,&httpd_merge_data, NULL, NULL);
if (httpd_full_buff_pos>0) {
saved_body.len = httpd_full_buff_pos;
saved_body.s = httpd_full_buff;
}
ret_code = cb->callback(cls, (void*)connection,
normalised_url,
method, version,
Expand Down Expand Up @@ -529,11 +550,6 @@ MHD_RET answer_to_connection (void *cls, struct MHD_Connection *connection,
err log printed in getConnectionHeader() */
return MHD_NO;
}
if (*upload_data_size != pr->content_len) {
/* For now, we don't support large POST with truncated data */
LM_ERR("got a truncated POST request\n");
return MHD_NO;
}
LM_DBG("got ContentType [%d] with len [%d]: %.*s\n",
pr->content_type, pr->content_len,
(int)*upload_data_size, upload_data);
Expand Down
Loading