Http Api Content-Type Not Respected


dch

Recommended Posts

Request Headers. Note Accept.

GET /api?method=get_folders HTTP/1.1Accept: application/jsonAccept-Encoding: gzip, deflate, compressAuthorization: Basic ASDFgfdsghstFDASGFDAGRADContent-Type: application/json; charset=utf-8Host: wintermute:8888User-Agent: HTTPie/0.8.0

Response Headers. Note Content-Type.

HTTP/1.1 200 OKCache-Control: no-cacheConnection: keep-aliveContent-Length: 654Content-Type: text/javascript

Content-Type should obviously be application/json -- we are not returning arbitrary JavaScript (aka JSONP) here.

 

This should be fixed because:

 

1. sent content-type should match the requested type within reason

2. it's clearly application/json data being returned anyway

3. downstream APIs and tools may not handle text/javascript in the same way

 

This specific example taken from FreeBSD 10.0 client. I'd suggest also you may want to consider including the btsync version in the returned headers. This will be useful in future for feature detection and operations.

 

Link to comment
Share on other sites

  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.