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

HTTP API - Content-Type should include charset #1817

Open
richardschneider opened this issue Oct 9, 2015 · 9 comments
Open

HTTP API - Content-Type should include charset #1817

richardschneider opened this issue Oct 9, 2015 · 9 comments
Labels
kind/bug A bug in existing code (including security flaws) topic/api Topic api topic/rpc-api Issues related to Kubo RPC API at /api/v0

Comments

@richardschneider
Copy link

When returning text/... and application/json the API should include the charset in the HTTP header.

Content-Type: application/json; charset=utf-8

See http://www.w3.org/International/O-HTTP-charset for more derails.

@richardschneider richardschneider changed the title Content-Type should include charset HTTP API - Content-Type should include charset Oct 10, 2015
@whyrusleeping whyrusleeping added the topic/gateway Topic gateway label Oct 11, 2015
@richardschneider
Copy link
Author

@whyrusleeping I found this issue in the HTTP API but it may also exist in gateway.

@jbenet
Copy link
Member

jbenet commented Oct 11, 2015

@richardschneider was this resolved?

@richardschneider
Copy link
Author

No it was not resolved

GET http://localhost:5001/api/v0/version HTTP/1.1
User-Agent: Fiddler
Host: localhost:5001

responds with

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked

1c
{
   "Version": "0.3.8-dev"
 }
0

@daviddias daviddias added the kind/bug A bug in existing code (including security flaws) label Jan 2, 2016
@rht
Copy link
Contributor

rht commented Jan 21, 2016

For gateway, this is already fixed in @AtnNn's #2008.
Though not yet for api.

@ingokeck
Copy link

That is actually a big issue. As the header is not set, the http/1.1 standard defines it to be the default ISO-8859-1, while JSON is utf8. So standard compliant clients will treat the response as ISO-8859-1 and may convert it to utf8 to decode the JSON content and then fail. Which now seems to happen to the python api?

@RichardLitt
Copy link
Member

There are also cases where the content-type should be different: x-gzip, x-tar, etc. ipfs-inactive/http-api-spec#46 #2427 #2376

ingokeck added a commit to ingokeck/py-ipfs-api that referenced this issue Mar 16, 2016
…his might relate to IPFS Bug #1817 ipfs/kubo#1817

* Added  test for get_pyobject() and add_pyobject() in test/functional/tests.py which works fine.

NB: Other tests in tests.py fail, there might be an issue with the multipart code. At the moment test/functional/tests.py is not evaluated by tox because setup.cfg limits tests to tests/unit.
@ghost ghost added topic/api Topic api and removed topic/gateway Topic gateway labels Sep 2, 2016
@richardschneider
Copy link
Author

Any progress? go-ipfs/0.4.7 still doesn't include the charset

HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Content-Type: application/json
Server: go-ipfs/0.4.7
Trailer: X-Stream-Error
Vary: Origin
Date: Sun, 12 Nov 2017 23:30:41 GMT
Transfer-Encoding: chunked

@richardschneider
Copy link
Author

Same error with go-ipfs/0.4.11

HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Content-Type: application/json
Server: go-ipfs/0.4.11
Trailer: X-Stream-Error
Vary: Origin
Date: Mon, 13 Nov 2017 00:26:33 GMT
Content-Length: 270

{"Arguments":{"Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD":"Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD"},"Objects":{"Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD":{"Hash":"Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD","Size":11,"Type":"File","Links":null}}}

@da2x
Copy link
Contributor

da2x commented Oct 4, 2018

This is a more generic issue than just having to do with content encoding.

E.g. text/csv; header means a comma-separated value file where the first line contains column headers.

@daviddias daviddias added the topic/rpc-api Issues related to Kubo RPC API at /api/v0 label Oct 8, 2019
gersonkevin23 added a commit to gersonkevin23/py-ipfs-http-client that referenced this issue Mar 3, 2022
…his might relate to IPFS Bug #1817 ipfs/kubo#1817

* Added  test for get_pyobject() and add_pyobject() in test/functional/tests.py which works fine.

NB: Other tests in tests.py fail, there might be an issue with the multipart code. At the moment test/functional/tests.py is not evaluated by tox because setup.cfg limits tests to tests/unit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) topic/api Topic api topic/rpc-api Issues related to Kubo RPC API at /api/v0
Projects
None yet
Development

No branches or pull requests

8 participants