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

Accept: image/* returns 406 #18

Open
robnoake opened this issue Feb 21, 2014 · 8 comments
Open

Accept: image/* returns 406 #18

robnoake opened this issue Feb 21, 2014 · 8 comments

Comments

@robnoake
Copy link
Contributor

Twitterbot is using Accept: image/* when it requests images from Darkroom, which is responding with a 406 error.

Example curl: curl -H"Accept: image/*" http://www.mytimesplus.co.uk/darkroom/1280/0/02cb1a3e56afae44ffc826329715daba:333948db2201b549b9a2d968fa58d165/gravity.jpg

Observed response:
{"code":"NotAcceptableError","message":"Server accepts: application/json,text/plain,application/octet-stream,application/javascript"}

Expected behaviour: Darkroom returns 200 with the image.

@serby
Copy link
Contributor

serby commented Feb 21, 2014

That seems weird? Accept and content-type must be wired up wrong.

@robnoake
Copy link
Contributor Author

This appears to be a "feature" of Restify. It doesn't have a plugin to handle responding to image MIME types, so it chucks an error back.

You can provide a static list of types you accept and respond to, but it applies blindly across all endpoints. In order to get the behaviour we want in Restify we would have to either delegate control over accept headers to the individual endpoints, or write a Restify plugin that knows how to match every endpoint URL and adapts what it accepts accordingly.

Neither of those are appealing options in my book.

''Edit: See following for more detail:''

Accept plugin:

Passing a list of acceptable types to the createServer function:

@tomgco
Copy link
Contributor

tomgco commented Feb 21, 2014

FYI i am dropping restify in the next ver of darkroom and going back to express / connect. Not sure on the solution to this, one could add a middleware to each required route.

@robnoake
Copy link
Contributor Author

@tomgco: I think middleware would be a reasonable solution, since you could return a function from the middleware that accepts specific types and have a few of those for each type of endpoint.

@serby
Copy link
Contributor

serby commented May 13, 2014

I've run the curl command and it is returning the image correctly for me.

  curl -H"Accept: image/*" http://www.mytimesplus.co.uk/darkroom/1280/0/02cb1a3e56afae44ffc826329715daba:333948db2201b549b9a2d968fa58d165/gravity.jpg

@robnoake
Copy link
Contributor Author

I have tried passing a query string just now in the URL originally reported and see the 406 message.

curl -v -H"Accept: image/*" http://www.mytimesplus.co.uk/darkroom/1280/0/02cb1a3e56afae44ffc826329715daba:333948db2201b549b9a2d968fa58d165/gravity.jpg\?1                              
* Adding handle: conn: 0x90ee00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x90ee00) send_pipe: 1, recv_pipe: 0
* About to connect() to www.mytimesplus.co.uk port 80 (#0)
*   Trying 23.63.99.48...
* Connected to www.mytimesplus.co.uk (23.63.99.48) port 80 (#0)
> GET /darkroom/1280/0/02cb1a3e56afae44ffc826329715daba:333948db2201b549b9a2d968fa58d165/gravity.jpg?1 HTTP/1.1
> User-Agent: curl/7.32.0
> Host: www.mytimesplus.co.uk
> Accept: image/*
> 
< HTTP/1.1 406 Not Acceptable
< Content-Type: application/json
< X-Clock-Backend: timesplus_production_darkroom_03
< Content-Length: 133
< Accept-Ranges: bytes
< X-Varnish: 403173526
< X-Served-By: times-varnish-01
< Date: Tue, 13 May 2014 11:05:08 GMT
< Connection: keep-alive
< 
* Connection #0 to host www.mytimesplus.co.uk left intact
{"code":"NotAcceptableError","message":"Server accepts: application/json,text/plain,application/octet-stream,application/javascript"}

@serby
Copy link
Contributor

serby commented Jun 18, 2014

I can confirm this happens.

@serby
Copy link
Contributor

serby commented Jun 18, 2014

I will confirm and close if I have fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants