Software / code / prosody
Comparison
net/http/parser.lua @ 6522:46cf369d3eb5
net.http.parser: Fix chunked encoding parsing across packet boundaries.
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Mon, 10 Nov 2014 14:47:33 -0500 |
| parent | 6386:f942cf2a9a03 |
| child | 6523:63d3126b75f1 |
comparison
equal
deleted
inserted
replaced
| 6509:7cb69eba3e95 | 6522:46cf369d3eb5 |
|---|---|
| 130 end | 130 end |
| 131 if chunk_size == 0 and buf:find("\r\n\r\n", chunk_start-2, true) then | 131 if chunk_size == 0 and buf:find("\r\n\r\n", chunk_start-2, true) then |
| 132 state, chunk_size = nil, nil; | 132 state, chunk_size = nil, nil; |
| 133 buf = buf:gsub("^.-\r\n\r\n", ""); -- This ensure extensions and trailers are stripped | 133 buf = buf:gsub("^.-\r\n\r\n", ""); -- This ensure extensions and trailers are stripped |
| 134 success_cb(packet); | 134 success_cb(packet); |
| 135 elseif #buf - chunk_start + 2 >= chunk_size then -- we have a chunk | 135 elseif #buf - chunk_start - 2 >= chunk_size then -- we have a chunk |
| 136 packet.body = packet.body..buf:sub(chunk_start, chunk_start + (chunk_size-1)); | 136 packet.body = packet.body..buf:sub(chunk_start, chunk_start + (chunk_size-1)); |
| 137 buf = buf:sub(chunk_start + chunk_size + 2); | 137 buf = buf:sub(chunk_start + chunk_size + 2); |
| 138 chunk_size, chunk_start = nil, nil; | 138 chunk_size, chunk_start = nil, nil; |
| 139 else -- Partial chunk remaining | 139 else -- Partial chunk remaining |
| 140 break; | 140 break; |