cpp-httplib
cpp-httplib copied to clipboard
Breaking change in handling requests with Range in v0.15.1 and v0.15.2
Request:
GET /range.bin HTTP/1.1
Host: 127.0.0.1:18080
Range: bytes=1000-
Accept: */*
Connection: TE
gzip
Accept-Language: en-us, en;q=0.9
The server .Get()
handler:
response.status = 401;
response.set_header("WWW-Authenticate", "Basic realm=123456");
Expected response:
HTTP/1.1 401 Unauthorized
Connection: close
Content-Length: 0
WWW-Authenticate: Basic realm=123456
Actual Response:
HTTP/1.1 416 Range Not Satisfiable
Connection: close
Content-Length: 0
WWW-Authenticate: Basic realm=123456
Here https://github.com/yhirose/cpp-httplib/commit/fceada9ef42ce1af64a1d5941d8009dd0520901a:
detail::normalize_ranges(req, res)
should not be called if res.status
is not 2xx or even is neither 200 nor 206.
There is a typo in the comment a few lines above that call:
--- // Rounting
+++ // Routing
@sergio-nsk thanks for the report. It's a bug. I'll take a look at it sometime this week.