mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
0c9ff0b45a
Implement a ReadJSON() utility to help reduce some code-duplication,
and to make sure we handle JSON requests consistently (e.g. always
check for the content-type).
Differences compared to current handling:
- prevent possible panic if request.Body is nil ("should never happen")
- always require Content-Type to be "application/json"
- be stricter about additional content after JSON (previously ignored)
- but, allow the body to be empty (an empty body is not invalid);
update TestContainerInvalidJSON accordingly, which was testing the
wrong expectation.
- close body after reading (some code did this)
We should consider to add a "max body size" on this function, similar to
|
||
---|---|---|
.. | ||
backend.go | ||
filter.go | ||
network.go | ||
network_routes.go |