Change content-type for json stream to application/x-json-stream.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
Upstream-commit: 10ab2089ce189d5bea3f7aaac3b5081471309478
Component: engine
This commit is contained in:
Jessica Frazelle
2014-09-17 17:53:04 -07:00
parent e9760e60ca
commit 7b47b2e708
5 changed files with 17 additions and 6 deletions

View File

@ -102,6 +102,10 @@ func writeJSON(w http.ResponseWriter, code int, v engine.Env) error {
func streamJSON(job *engine.Job, w http.ResponseWriter, flush bool) {
w.Header().Set("Content-Type", "application/json")
if job.GetenvBool("lineDelim") {
w.Header().Set("Content-Type", "application/x-json-stream")
}
if flush {
job.Stdout.Add(utils.NewWriteFlusher(w))
} else {
@ -976,6 +980,7 @@ func postBuild(eng *engine.Engine, version version.Version, w http.ResponseWrite
job.Setenv("q", r.FormValue("q"))
job.Setenv("nocache", r.FormValue("nocache"))
job.Setenv("forcerm", r.FormValue("forcerm"))
job.SetenvBool("lineDelim", version.GreaterThanOrEqualTo("1.15"))
job.SetenvJson("authConfig", authConfig)
job.SetenvJson("configFile", configFile)

View File

@ -275,7 +275,7 @@ func TestGetEvents(t *testing.T) {
if !called {
t.Fatal("handler was not called")
}
assertContentType(r, "application/json", t)
assertContentType(r, "application/x-json-stream", t)
var stdout_json struct {
Since int
Until int