MINOR: http: check the algo name "identity" instead of the function pointer

Next patch will statity all compression functions, so let's stop relying
on a function pointer comparison and use the algo name instead.
This commit is contained in:
Willy Tarreau 2015-03-28 15:41:42 +01:00
parent 2aee2215c9
commit e7e49a8d0b

View File

@ -2333,7 +2333,7 @@ int select_compression_request_header(struct session *s, struct buffer *req)
/* identity is implicit does not require headers */
if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) || (s->fe->comp && (comp_algo_back = s->fe->comp->algos))) {
for (comp_algo = comp_algo_back; comp_algo; comp_algo = comp_algo->next) {
if (comp_algo->add_data == identity_add_data) {
if (comp_algo->name_len == 8 && memcmp(comp_algo->name, "identity", 8) == 0) {
s->comp_algo = comp_algo;
return 1;
}
@ -2445,7 +2445,7 @@ int select_compression_response_header(struct session *s, struct buffer *res)
* Accept-Encoding header, and SHOULD NOT be used in the Content-Encoding
* header.
*/
if (s->comp_algo->add_data != identity_add_data) {
if (s->comp_algo->name_len != 8 || memcmp(s->comp_algo->name, "identity", 8) != 0) {
trash.len = 18;
memcpy(trash.str, "Content-Encoding: ", trash.len);
memcpy(trash.str + trash.len, s->comp_algo->name, s->comp_algo->name_len);