Return 400 status instead of 500 for empty volume create body
| ... | ... |
@@ -2,11 +2,14 @@ package volume |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 |
+ "errors" |
|
| 6 |
+ "io" |
|
| 5 | 7 |
"net/http" |
| 6 | 8 |
|
| 7 | 9 |
"github.com/docker/docker/api/server/httputils" |
| 8 | 10 |
"github.com/docker/docker/api/types/filters" |
| 9 | 11 |
volumetypes "github.com/docker/docker/api/types/volume" |
| 12 |
+ "github.com/docker/docker/errdefs" |
|
| 10 | 13 |
"golang.org/x/net/context" |
| 11 | 14 |
) |
| 12 | 15 |
|
| ... | ... |
@@ -45,6 +48,9 @@ func (v *volumeRouter) postVolumesCreate(ctx context.Context, w http.ResponseWri |
| 45 | 45 |
|
| 46 | 46 |
var req volumetypes.VolumesCreateBody |
| 47 | 47 |
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
| 48 |
+ if err == io.EOF {
|
|
| 49 |
+ return errdefs.InvalidParameter(errors.New("got EOF while reading request body"))
|
|
| 50 |
+ } |
|
| 48 | 51 |
return err |
| 49 | 52 |
} |
| 50 | 53 |
|