diff options
Diffstat (limited to 'src/http.lua')
| -rw-r--r-- | src/http.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/http.lua b/src/http.lua index 21d3078..6cdc90a 100644 --- a/src/http.lua +++ b/src/http.lua | |||
| @@ -360,6 +360,7 @@ local trequest, tredirect | |||
| 360 | headers = reqt.headers, | 360 | headers = reqt.headers, |
| 361 | proxy = reqt.proxy, | 361 | proxy = reqt.proxy, |
| 362 | maxredirects = reqt.maxredirects, | 362 | maxredirects = reqt.maxredirects, |
| 363 | response_headers = reqt.response_headers, | ||
| 363 | nredirects = (reqt.nredirects or 0) + 1, | 364 | nredirects = (reqt.nredirects or 0) + 1, |
| 364 | create = reqt.create | 365 | create = reqt.create |
| 365 | } | 366 | } |
| @@ -403,6 +404,17 @@ end | |||
| 403 | return tredirect(reqt, headers.location) | 404 | return tredirect(reqt, headers.location) |
| 404 | end | 405 | end |
| 405 | -- here we are finally done | 406 | -- here we are finally done |
| 407 | -- provide an opportunity to abort or replace the sink based on the response headers | ||
| 408 | if nreqt.response_headers then | ||
| 409 | local abort, sink = nreqt.response_headers(code, headers, status) | ||
| 410 | if abort then | ||
| 411 | h:close() | ||
| 412 | return 1, code, headers, status | ||
| 413 | end | ||
| 414 | if sink then | ||
| 415 | nreqt.sink = sink | ||
| 416 | end | ||
| 417 | end | ||
| 406 | if shouldreceivebody(nreqt, code) then | 418 | if shouldreceivebody(nreqt, code) then |
| 407 | h:receivebody(headers, nreqt.sink, nreqt.step) | 419 | h:receivebody(headers, nreqt.sink, nreqt.step) |
| 408 | end | 420 | end |
