moby--moby/api/server/router
Sebastiaan van Stijn 5ad1e4be6b
Return 400 status instead of 500 for empty volume create body
The `POST /volumes/create` expects a request body to be provided.
If no body was provided, a 500 status was returned. A 500 status
is incorrect, because the request is invalid (it's not a server
error).

Before this change:

    $ curl --unix-socket /var/run/docker.sock -v -X POST http://localhost/volumes/create

    *   Trying /var/run/docker.sock...
    * Connected to localhost (/Users/sebastiaan/Library/Containers/com.dock) port 80 (#0)
    > POST /volumes/create HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.51.0
    > Accept: */*
    >
    < HTTP/1.1 500 Internal Server Error
    < Api-Version: 1.30
    < Content-Length: 18
    < Content-Type: application/json
    < Date: Wed, 19 Jul 2017 11:29:26 GMT
    < Docker-Experimental: true
    < Ostype: linux
    < Server: Docker/17.06.0-ce (linux)
    <
    {"message":"EOF"}
    * Curl_http_done: called premature == 0
    * Connection #0 to host localhost left intact

After this change:

    $ curl --unix-socket /var/run/docker.sock -v -X POST http://localhost/volumes/create

    *   Trying /var/run/docker.sock...
    * Connected to localhost (/var/run/docker.sock) port 80 (#0)
    > POST /volumes/create HTTP/1.1
    > Host: localhost
    > User-Agent: curl/7.52.1
    > Accept: */*
    >
    < HTTP/1.1 400 Bad Request
    < Api-Version: 1.36
    < Content-Type: application/json
    < Docker-Experimental: false
    < Ostype: linux
    < Server: Docker/dev (linux)
    < Date: Tue, 09 Jan 2018 15:00:13 GMT
    < Content-Length: 42
    <
    {"message":"no body provided in request"}
    * Curl_http_done: called premature == 0
    * Connection #0 to host localhost left intact

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-01-16 20:42:44 +01:00
..
build Move api/errdefs to errdefs 2018-01-11 21:21:43 -05:00
checkpoint Use function arguments for route setup. 2017-04-12 08:43:51 -04:00
container Move api/errdefs to errdefs 2018-01-11 21:21:43 -05:00
debug Enable pprof/debug endpoints by default 2017-07-17 15:01:30 -04:00
distribution api: Only return a Platform when relevant information is available 2017-05-17 18:42:16 -07:00
image Move api/errdefs to errdefs 2018-01-11 21:21:43 -05:00
network Merge pull request #36021 from yongtang/30897-follow-up 2018-01-16 09:38:16 +01:00
plugin Replace uses of filters.ToParam(), FromParam() with filters.ToJSON(), FromJSON() 2017-09-26 13:59:45 +02:00
session Move api/errdefs to errdefs 2018-01-11 21:21:43 -05:00
swarm Move api/errdefs to errdefs 2018-01-11 21:21:43 -05:00
system api: generalize version information to any platform component 2017-12-06 23:23:55 +01:00
volume Return 400 status instead of 500 for empty volume create body 2018-01-16 20:42:44 +01:00
experimental.go Remove string checking in API error handling 2017-08-15 16:01:11 -04:00
local.go Use function arguments for route setup. 2017-04-12 08:43:51 -04:00
router.go