{"action":"created","issue":{"url":"https://api.github.com/repos/apocas/docker-modem/issues/81","repository_url":"https://api.github.com/repos/apocas/docker-modem","labels_url":"https://api.github.com/repos/apocas/docker-modem/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/apocas/docker-modem/issues/81/comments","events_url":"https://api.github.com/repos/apocas/docker-modem/issues/81/events","html_url":"https://github.com/apocas/docker-modem/issues/81","id":233448735,"number":81,"title":"Sending non-empty body for some requests breaks docker > 1.12","user":{"login":"rmg","id":17978,"avatar_url":"https://avatars1.githubusercontent.com/u/17978?v=3","gravatar_id":"","url":"https://api.github.com/users/rmg","html_url":"https://github.com/rmg","followers_url":"https://api.github.com/users/rmg/followers","following_url":"https://api.github.com/users/rmg/following{/other_user}","gists_url":"https://api.github.com/users/rmg/gists{/gist_id}","starred_url":"https://api.github.com/users/rmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmg/subscriptions","organizations_url":"https://api.github.com/users/rmg/orgs","repos_url":"https://api.github.com/users/rmg/repos","events_url":"https://api.github.com/users/rmg/events{/privacy}","received_events_url":"https://api.github.com/users/rmg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-06-04T17:55:05Z","updated_at":"2017-06-04T20:44:43Z","closed_at":null,"body":"Example of error:\r\n> starting container with non-empty request body was deprecated since v1.10 and removed in v1.12\r\n\r\nThis is caused by `modem.dial` sending `{}` and setting `Transfer-Encoding: chunked` on `POST` methods when no body is specified.\r\n\r\nHere's a quick hack to work around it, illustrating the problem bits:\r\n```patch\r\ndiff --git a/lib/modem.js b/lib/modem.js\r\nindex a096ad9..0b1f2db 100644\r\n--- a/lib/modem.js\r\n+++ b/lib/modem.js\r\n@@ -140,14 +140,18 @@ Modem.prototype.dial = function(options, callback) {\r\n     optionsf.headers['Content-Type'] = 'application/tar';\r\n   } else if (opts && options.method === 'POST') {\r\n     data = JSON.stringify(opts._body || opts);\r\n-    optionsf.headers['Content-Type'] = 'application/json';\r\n+    if (data !== '{}' && data !== '\"\"') {\r\n+      optionsf.headers['Content-Type'] = 'application/json';\r\n+    } else {\r\n+      data = undefined;\r\n+    }\r\n   }\r\n\r\n   if (typeof data === \"string\") {\r\n     optionsf.headers['Content-Length'] = Buffer.byteLength(data);\r\n   } else if (Buffer.isBuffer(data) === true) {\r\n     optionsf.headers['Content-Length'] = data.length;\r\n-  } else if (optionsf.method === 'POST' || optionsf.method === 'PUT') {\r\n+  } else if (optionsf.method === 'PUT' || options.hijack || options.openStdin) {\r\n     // Has body\r\n     optionsf.headers['Transfer-Encoding'] = 'chunked';\r\n   }\r\n```"},"comment":{"url":"https://api.github.com/repos/apocas/docker-modem/issues/comments/306065665","html_url":"https://github.com/apocas/docker-modem/issues/81#issuecomment-306065665","issue_url":"https://api.github.com/repos/apocas/docker-modem/issues/81","id":306065665,"user":{"login":"apocas","id":597413,"avatar_url":"https://avatars0.githubusercontent.com/u/597413?v=3","gravatar_id":"","url":"https://api.github.com/users/apocas","html_url":"https://github.com/apocas","followers_url":"https://api.github.com/users/apocas/followers","following_url":"https://api.github.com/users/apocas/following{/other_user}","gists_url":"https://api.github.com/users/apocas/gists{/gist_id}","starred_url":"https://api.github.com/users/apocas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apocas/subscriptions","organizations_url":"https://api.github.com/users/apocas/orgs","repos_url":"https://api.github.com/users/apocas/repos","events_url":"https://api.github.com/users/apocas/events{/privacy}","received_events_url":"https://api.github.com/users/apocas/received_events","type":"User","site_admin":false},"created_at":"2017-06-04T20:44:43Z","updated_at":"2017-06-04T20:44:43Z","body":"`\r\n    if (data !== '{}' && data !== '\"\"') {\r\n      optionsf.headers['Content-Type'] = 'application/json';\r\n    } else {\r\n      data = undefined;\r\n    }\r\n`\r\n\r\nSomething is weird. With this fix, run exec test fails with 500 and \"{\"message\":\"EOF\"}\"\r\n\r\nUsing what's in master right now, I can start a container without options."}}
{"actor":{"display_login":"apocas"}}