Commit graph

6 commits

Author SHA1 Message Date
Yong Tang
c8844a8555
Replace io.LimitReader with http.MaxBytesReader (#5241)
Previously we use io.LimitReader to limit the number of bytes
from http request. However, there is a subtle difference between
io.LimitReader and io.ReadAll as io.LimitReader will return
a Reader, not a ReadCloser. As such the behavior will actually
be difference in case of error handling (and when to close).

This PR changes io.LimitReader to http.MaxBytesReader
so that the behavior can be preserved (except the number of bytes).
See https://stackoverflow.com/a/52699702

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-04-04 15:02:08 -04:00
Yong Tang
ad41112a92
Add limit to ioutil.ReadAll for request body (#5224)
This PR adds limit to ioutil.ReadAll for DoH request body
so that it will not be subject to large requests.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2022-03-04 12:18:05 -08:00
Zou Nengren
5191959bd7
cleanup deprecated package io/ioutil (#4920)
Signed-off-by: zounengren <zouyee1989@gmail.com>
2021-10-13 09:30:31 +02:00
Miek Gieben
9178f9d1ee
Remove newlines between braces (#4279)
These are found with: `pcregrep -M "}\n\n}" **/*.go`
Sometimes a unneeded newline is inserted, remove those.

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-11-11 18:45:01 +01:00
Karsten Weiss
6d8a078704 Typo fixes (#2031) 2018-08-14 08:55:55 -07:00
Miek Gieben
30a788fd3a
Doh: put in pkg/doh (#1946)
* DoH: put in pkg/doh

Factor out the DoH stuff into its own package, add function to request
a DoH response. This can be used by forward (and maybe proxy) to
implement DoH client support.

Signed-off-by: Miek Gieben <miek@miek.nl>

* lint

Signed-off-by: Miek Gieben <miek@miek.nl>

* ... and make it compile

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-07 08:22:07 +01:00