Hi,
This code appears in gwlib/http.c and is called by return_reply as part of
resetting headers for returning them to the mobile. It seems to me that the
first part is a needless loop, for something that follows,
http_header_remove_all(headers, "Connection"). I would welcome if you could
shed some light on why this is done so. The bold part creates and deatroys
lists and seems to me that the only thing it does is to destroy the
"Connection:" headers, which are destroyed anyway in the next call. Can it be
removed safely, or am I missing something obvious?
Thanx,
Nikos
void http_remove_hop_headers(List *headers)
{
Octstr *h;
List *connection_headers;
gwlib_assert_init();
gw_assert(headers != NULL);
/*
* The hop-by-hop headers are a standard list, plus those named
* in the Connection header(s).
*/
connection_headers = http_header_find_all(headers, "Connection");
while ((h = gwlist_consume(connection_headers))) {
List *hop_headers;
Octstr *e;
octstr_delete(h, 0, strlen("Connection:"));
hop_headers = http_header_split_value(h);
octstr_destroy(h);
while ((e = gwlist_consume(hop_headers))) {
http_header_remove_all(headers, octstr_get_cstr(e));
octstr_destroy(e);
}
gwlist_destroy(hop_headers, NULL);
}
gwlist_destroy(connection_headers, NULL);
http_header_remove_all(headers, "Connection");
http_header_remove_all(headers, "Keep-Alive");
http_header_remove_all(headers, "Proxy-Authenticate");
http_header_remove_all(headers, "Proxy-Authorization");
http_header_remove_all(headers, "TE");
http_header_remove_all(headers, "Trailers");
http_header_remove_all(headers, "Transfer-Encoding");
http_header_remove_all(headers, "Upgrade");
}