MCPcopy Create free account
hub / github.com/apache/httpd / fix_encoding

Function fix_encoding

modules/mappers/mod_negotiation.c:3163–3205  ·  view source on GitHub ↗

* There is a problem with content-encoding, as some clients send and * expect an x- token (e.g. x-gzip) while others expect the plain token * (i.e. gzip). To try and deal with this as best as possible we do * the following: if the client sent an Accept-Encoding header and it * contains a plain token corresponding to the content encoding of the * response, then set content encoding using the p

Source from the content-addressed store, hash-verified

3161 * directive.
3162 */
3163static int fix_encoding(request_rec *r)
3164{
3165 const char *enc = r->content_encoding;
3166 char *x_enc = NULL;
3167 apr_array_header_t *accept_encodings;
3168 accept_rec *accept_recs;
3169 int i;
3170
3171 if (!enc || !*enc) {
3172 return DECLINED;
3173 }
3174
3175 if (enc[0] == 'x' && enc[1] == '-') {
3176 enc += 2;
3177 }
3178
3179 if ((accept_encodings = do_header_line(r->pool,
3180 apr_table_get(r->headers_in, "Accept-Encoding"))) == NULL) {
3181 return DECLINED;
3182 }
3183
3184 accept_recs = (accept_rec *) accept_encodings->elts;
3185
3186 for (i = 0; i < accept_encodings->nelts; ++i) {
3187 char *name = accept_recs[i].name;
3188
3189 if (!strcmp(name, enc)) {
3190 r->content_encoding = name;
3191 return OK;
3192 }
3193
3194 if (name[0] == 'x' && name[1] == '-' && !strcmp(name+2, enc)) {
3195 x_enc = name;
3196 }
3197 }
3198
3199 if (x_enc) {
3200 r->content_encoding = x_enc;
3201 return OK;
3202 }
3203
3204 return DECLINED;
3205}
3206
3207static void register_hooks(apr_pool_t *p)
3208{

Callers

nothing calls this directly

Calls 1

do_header_lineFunction · 0.85

Tested by

no test coverage detected