OnroerendErfgoed / skosprovider_atramhasis

A skosprovider that can talk to an Atramhasis instance
http://skosprovider-atramhasis.readthedocs.org
MIT License
2 stars 0 forks source link

Encoding of a json response #4

Closed koenedaele closed 9 years ago

koenedaele commented 9 years ago

I noticed in https://github.com/OnroerendErfgoed/skosprovider_atramhasis/blob/master/skosprovider_atramhasis/providers.py#L63 that we manually assign an encoding to a response. I assume this means that requests can't figure out the correct encoding automatically? Does this mean that we need to do something extra on the Atramhasis side? Or do we need to tell requests to figure it out automatically? Anyone know why we're doing this and if we actually need to do this?

/cc @dieuska @BartSaelen

dieuska commented 9 years ago

Requests tries to figure out the enocing based on the response header. Because the encoding is not set in response header the encoding is automatically set to None (and we are setting it manually to utf-8) http://docs.python-requests.org/en/latest/user/quickstart/#response-content It would indeed be better that encoding is given in the response headers of the atramhasis-services so requests can figure it out automatically.

koenedaele commented 9 years ago

Strange thing is, when I test a call to http://localhost:6543/conceptschemes/STYLES with the Chrome Advanced REST Client, get the following headers:

Content-Length: 101 
Content-Type: application/json; charset=UTF-8 
Date: Thu, 29 Jan 2015 14:03:46 GMT 
Server: waitress 

So, there's a charset present. Is this different when you use requests?

dieuska commented 9 years ago

you are right, I also get the encoding, and requests can automatically discover it. The problem why i did not saw the enoding: I already mocked the answers that the tests can be executed on travis, but the mocked responses did not return the encoding. (i ll ckeck if i can add that)