diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2006-04-12 08:04:09 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2006-04-12 08:04:09 +0000 |
| commit | be57b387d2394cc670b37e04edab41e293d47560 (patch) | |
| tree | 96e3e626a83eeb203af9a074bca8febfecff0cc8 | |
| parent | 11282d17c8ecb6aa6fa31a3de742eae0215f4cc0 (diff) | |
| download | luasocket-be57b387d2394cc670b37e04edab41e293d47560.tar.gz luasocket-be57b387d2394cc670b37e04edab41e293d47560.tar.bz2 luasocket-be57b387d2394cc670b37e04edab41e293d47560.zip | |
Stupid bug was reusing the nreqt.headers.host during redirect.
| -rw-r--r-- | TODO | 10 | ||||
| -rw-r--r-- | src/http.lua | 19 |
2 files changed, 19 insertions, 10 deletions
| @@ -1,3 +1,13 @@ | |||
| 1 | New mime support | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 | |||
| 8 | |||
| 9 | |||
| 10 | |||
| 1 | ftp send should return server replies? | 11 | ftp send should return server replies? |
| 2 | make sure there are no object files in the distribution tarball | 12 | make sure there are no object files in the distribution tarball |
| 3 | http handling of 100-continue, see DB patch | 13 | http handling of 100-continue, see DB patch |
diff --git a/src/http.lua b/src/http.lua index bfa0345..6465c29 100644 --- a/src/http.lua +++ b/src/http.lua | |||
| @@ -15,7 +15,6 @@ local mime = require("mime") | |||
| 15 | local string = require("string") | 15 | local string = require("string") |
| 16 | local base = _G | 16 | local base = _G |
| 17 | local table = require("table") | 17 | local table = require("table") |
| 18 | local print = print | ||
| 19 | module("socket.http") | 18 | module("socket.http") |
| 20 | 19 | ||
| 21 | ----------------------------------------------------------------------------- | 20 | ----------------------------------------------------------------------------- |
| @@ -278,16 +277,16 @@ end | |||
| 278 | function trequest(reqt) | 277 | function trequest(reqt) |
| 279 | -- we loop until we get what we want, or | 278 | -- we loop until we get what we want, or |
| 280 | -- until we are sure there is no way to get it | 279 | -- until we are sure there is no way to get it |
| 281 | reqt = adjustrequest(reqt) | 280 | local nreqt = adjustrequest(reqt) |
| 282 | local h = open(reqt.host, reqt.port, reqt.create) | 281 | local h = open(nreqt.host, nreqt.port, nreqt.create) |
| 283 | -- send request line and headers | 282 | -- send request line and headers |
| 284 | h:sendrequestline(reqt.method, reqt.uri) | 283 | h:sendrequestline(nreqt.method, nreqt.uri) |
| 285 | h:sendheaders(reqt.headers) | 284 | h:sendheaders(nreqt.headers) |
| 286 | local code = 100 | 285 | local code = 100 |
| 287 | local headers, status | 286 | local headers, status |
| 288 | -- if there is a body, check for server status | 287 | -- if there is a body, check for server status |
| 289 | if reqt.source then | 288 | if nreqt.source then |
| 290 | h:sendbody(reqt.headers, reqt.source, reqt.step) | 289 | h:sendbody(nreqt.headers, nreqt.source, nreqt.step) |
| 291 | end | 290 | end |
| 292 | -- ignore any 100-continue messages | 291 | -- ignore any 100-continue messages |
| 293 | while code == 100 do | 292 | while code == 100 do |
| @@ -296,13 +295,13 @@ function trequest(reqt) | |||
| 296 | end | 295 | end |
| 297 | -- at this point we should have a honest reply from the server | 296 | -- at this point we should have a honest reply from the server |
| 298 | -- we can't redirect if we already used the source, so we report the error | 297 | -- we can't redirect if we already used the source, so we report the error |
| 299 | if shouldredirect(reqt, code, headers) and not reqt.source then | 298 | if shouldredirect(nreqt, code, headers) and not nreqt.source then |
| 300 | h:close() | 299 | h:close() |
| 301 | return tredirect(reqt, headers.location) | 300 | return tredirect(reqt, headers.location) |
| 302 | end | 301 | end |
| 303 | -- here we are finally done | 302 | -- here we are finally done |
| 304 | if shouldreceivebody(reqt, code) then | 303 | if shouldreceivebody(nreqt, code) then |
| 305 | h:receivebody(headers, reqt.sink, reqt.step) | 304 | h:receivebody(headers, nreqt.sink, nreqt.step) |
| 306 | end | 305 | end |
| 307 | h:close() | 306 | h:close() |
| 308 | return 1, code, headers, status | 307 | return 1, code, headers, status |
