Add newlines to the JSON stream functions#4276
Merged
crosbymichael merged 1 commit intomoby:masterfrom Feb 27, 2014
Merged
Conversation
This makes the JSON streams a _lot_ easier to parse in less well-baked JSON parsers, and no less so in better ones. Line-based JSON streams are very, very common, where simply chunk-based is not very common at all. Docker-DCO-1.1-Signed-off-by: Andrew Page <[email protected]> (github: tianon)
Member
Author
|
/cc @vieux |
SvenDowideit
added a commit
to SvenDowideit/docker
that referenced
this pull request
Feb 21, 2014
Docker-DCO-1.1-Signed-off-by: Sven Dowideit <[email protected]> (github: SvenDowideit)
metalivedev
added a commit
that referenced
this pull request
Feb 21, 2014
small update to API docs to go with #4276
Contributor
|
LGTM |
Contributor
|
LGTM |
crosbymichael
added a commit
that referenced
this pull request
Feb 27, 2014
Add newlines to the JSON stream functions
aanand
added a commit
to aanand/docker-py
that referenced
this pull request
Apr 23, 2014
Docker introduced newlines in stream output in version 0.9 (moby/moby#4276), but not to all endpoints - POST /images/create, for example, does not include them. This reverts to the old, less pleasant implementation of _stream_helper(), with a manual check for newlines to fix the problem described in docker#176 and fixed in docker#184, without the accompanying regression. It should work against Docker 0.8, 0.9 and 0.10, both when building and when pulling.
aanand
added a commit
to aanand/docker-py
that referenced
this pull request
Apr 23, 2014
Docker introduced newlines in stream output in version 0.9 (moby/moby#4276), but not to all endpoints - POST /images/create, for example, does not include them. This reverts to the old, less pleasant implementation of _stream_helper(), with a manual check for newlines to fix the problem described in docker#176 and fixed in docker#184, without the accompanying regression. It should work against Docker 0.8, 0.9 and 0.10, both when building and when pulling.
aanand
added a commit
to aanand/docker-py
that referenced
this pull request
Apr 28, 2014
Docker introduced newlines in stream output in version 0.9 (moby/moby#4276), but not to all endpoints - POST /images/create, for example, does not include them. This reverts to the old, less pleasant implementation of _stream_helper(), with a manual check for newlines to fix the problem described in docker#176 and fixed in docker#184, without the accompanying regression. It should work against Docker 0.8, 0.9 and 0.10, both when building and when pulling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes the JSON streams a lot easier to parse in less well-baked JSON parsers, and no less so in better ones.
Line-based JSON streams are very, very common, where simply chunk-based is not very common at all.
If you want a really pretty way to test this, start the compiled daemon listening on a TCP socket and run something like this (and watch it stream all pretty-like, right before your very eyes):
(see also https://gist.github.com/tianon/9129512 for more masochism along similar lines)
This came about from a discussion on IRC: https://botbot.me/freenode/docker/msg/11203433/
I also looked into swapping the Content-Type returned for these streams to something more like "application/x-json-stream", but that looked like it would be a bit more non-trivial (since the StreamFormatter is used in several places).