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
Wrong Content-Type in response of Remote API to the GET stats request #16514
Comments
Stats never returned application/json to my knowledge, as it's not actually application/json. This is a stream, not a singular response. You can get application/json if you use the |
It responded "application/json" with Remote API 1.17, Docker 1.5.0. You are right that the stream itself is not really "application/json", but each line (or block) in this stream is. For me its awkward (and it took some time to debug) that the type changes just because its either "one" or "many" of the output. I just want to take the body of the response and put it in the parser that is denoted by the type that is defined in the header of the response - no matter if I do this once or each second. With the response "text/plain", I have to hard code that the response to the "stats" request has to be handled by the json parser. If this changes, I have to change my code. Thats not how it should be. |
Hmmm, you're right. Looks like this probably changed in 1.7 with some big architectural refactorings. |
@cpuguy83 have you had time to look into these changes? |
Yes, this is problematic. |
That said, we can probably make the change for the stats endpoint. |
It could be versioned to keep the "old" behavior for older clients/api-versions |
For stats yes, for other endpoints, no. |
Description of problem:
Using the Remote API, in the response to the GET request for the stats of a container the "Content-Type" is "text/plain; charset=utf-8", but should be "application/json", like it was in earlier versions of the Remote API.
The problem is that parsers rely on the "Content-Type".
docker version
:Client:
Version: 1.8.2
API version: 1.20
Go version: go1.4.2
Git commit: 0a8c2e3
Built: Thu Sep 10 19:19:00 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.8.2
API version: 1.20
Go version: go1.4.2
Git commit: 0a8c2e3
Built: Thu Sep 10 19:19:00 UTC 2015
OS/Arch: linux/amd64
docker info
:Containers: 98
Images: 9
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 211
Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-63-generic
Operating System: Ubuntu 14.04.3 LTS
CPUs: 4
Total Memory: 7.664 GiB
Name: sirius.mydomain.test
ID: OKAA:4QF6:6QJ4:R4SE:IWFG:YJLY:PFFW:YTEK:URCB:MTCV:QCOY:VP3Y
WARNING: No swap limit support
uname -a
:Linux sirius.mydomain.test 3.13.0-63-generic #103-Ubuntu SMP Fri Aug 14 21:42:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Environment details (AWS, VirtualBox, physical, etc.):
Physical
How reproducible:
Always
Steps to Reproduce:
$ echo -e "GET /containers/4d50a1065a88/stats HTTP/1.1\r\n" | sudo nc -q -1 -U /var/run/docker.sock
Actual Results:
HTTP/1.1 200 OK
Server: Docker/1.8.2 (linux)
Date: Wed, 23 Sep 2015 08:04:40 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
[...]
Expected Results:
HTTP/1.1 200 OK
Server: Docker/1.8.2 (linux)
Date: Wed, 23 Sep 2015 08:04:40 GMT
Content-Type: application/json
Transfer-Encoding: chunked
[...]
Additional info:
I didn't find another response yet that reports the wrong Content-Type, but also didn't check many yet.
The text was updated successfully, but these errors were encountered: