Normalizing the Accept header
Difficulty level: Medium
Objective
This challenge includes both a template for the accept.media_lookup
function, as well as five unique test requests.
Each request includes a different Accept
header value, which needs to be normalized prior to passing to the origin. Although the normalization is handled by the accept.media_lookup
function, it is your job to fill in the function with the proper values so that when the code runs, the preferred Accept
values are sent for each test request. The test requests we send and the expected transformation of the Accept
header are shown below:
Client request's Accept header | Expected origin request's Accept header |
---|---|
application/, application/vnd.api+json, text/html;q=0.9, /*;q=0.1, | application/vnd.api+json |
application/* | application/x-www-form-urlencoded |
/ | text/html |
text/css, text/html, text/xml, text/csv, text/plain, image/png, image/jpeg, image/gif | image/jpeg |
text/, application/;q=0.9, /;q=0.1, | text/plain |
Fill in the accept.media_lookup
template to ensure the Accept
header that is passed to the origin for each request satisfies the test assigned to that given request. You can see what each request is expecting for the Accept
value by looking at the test associated with that request.