aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2001-09-26 20:40:13 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2001-09-26 20:40:13 +0000
commit164d33894e997b179dae93b7883b1f04f937ab8e (patch)
tree7ba2d3c9ba5fcc4c67a6f2bdedadde2f0a2ba573
parent84e503afe3c6ea684663272df1a7de1da85a20b7 (diff)
downloadluasocket-164d33894e997b179dae93b7883b1f04f937ab8e.tar.gz
luasocket-164d33894e997b179dae93b7883b1f04f937ab8e.tar.bz2
luasocket-164d33894e997b179dae93b7883b1f04f937ab8e.zip
Removed wrong host header in redirect.
Passing location header back to callee after redirect. Added correct scheme test.
-rw-r--r--src/http.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/http.lua b/src/http.lua
index 2e8c8e9..e4c756f 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -396,11 +396,11 @@ function Private.fill_headers(headers, parsed)
396 headers = headers or {} 396 headers = headers or {}
397 -- set default headers 397 -- set default headers
398 lower["user-agent"] = %Public.USERAGENT 398 lower["user-agent"] = %Public.USERAGENT
399 lower["host"] = parsed.host
400 -- override with user values 399 -- override with user values
401 for i,v in headers do 400 for i,v in headers do
402 lower[strlower(i)] = v 401 lower[strlower(i)] = v
403 end 402 end
403 lower["host"] = parsed.host
404 -- this cannot be overriden 404 -- this cannot be overriden
405 lower["connection"] = "close" 405 lower["connection"] = "close"
406 return lower 406 return lower
@@ -482,7 +482,10 @@ function Private.redirect(request, response)
482 body_cb = request.body_cb, 482 body_cb = request.body_cb,
483 headers = request.headers 483 headers = request.headers
484 } 484 }
485 return %Public.request_cb(redirect, response) 485 local response = %Public.request_cb(redirect, response)
486 -- we pass the location header as a clue we tried to redirect
487 if response.headers then response.headers.location = redirect.url end
488 return response
486end 489end
487 490
488----------------------------------------------------------------------------- 491-----------------------------------------------------------------------------
@@ -542,8 +545,13 @@ function Public.request_cb(request, response)
542 local parsed = URL.parse_url(request.url, { 545 local parsed = URL.parse_url(request.url, {
543 host = "", 546 host = "",
544 port = %Public.PORT, 547 port = %Public.PORT,
545 path ="/" 548 path ="/",
549 scheme = "http"
546 }) 550 })
551 if parsed.scheme ~= "http" then
552 response.error = format("unknown scheme '%s'", parsed.scheme)
553 return response
554 end
547 -- explicit authentication info overrides that given by the URL 555 -- explicit authentication info overrides that given by the URL
548 parsed.user = request.user or parsed.user 556 parsed.user = request.user or parsed.user
549 parsed.password = request.password or parsed.password 557 parsed.password = request.password or parsed.password