diff options
author | Charles Tabor <chastabor@gmail.com> | 2014-03-27 14:40:04 -0500 |
---|---|---|
committer | Charles Tabor <chastabor@gmail.com> | 2014-03-27 14:40:04 -0500 |
commit | 2314235b3ac62f5519177efadc2a738fd7224ee4 (patch) | |
tree | eed6ad8d866f96a36cd490657ca7ba6244846187 | |
parent | 36aa87e03158451df8e51bf8dcd3942134e3d8d8 (diff) | |
download | luasocket-2314235b3ac62f5519177efadc2a738fd7224ee4.tar.gz luasocket-2314235b3ac62f5519177efadc2a738fd7224ee4.tar.bz2 luasocket-2314235b3ac62f5519177efadc2a738fd7224ee4.zip |
Add proxy authentication headers if present.
-rw-r--r-- | src/http.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/http.lua b/src/http.lua index 204a841..2b4a45e 100644 --- a/src/http.lua +++ b/src/http.lua | |||
@@ -222,6 +222,15 @@ local function adjustheaders(reqt) | |||
222 | lower["authorization"] = | 222 | lower["authorization"] = |
223 | "Basic " .. (mime.b64(reqt.user .. ":" .. reqt.password)) | 223 | "Basic " .. (mime.b64(reqt.user .. ":" .. reqt.password)) |
224 | end | 224 | end |
225 | -- if we have proxy authentication information, pass it along | ||
226 | local proxy = reqt.proxy or _M.PROXY | ||
227 | if proxy then | ||
228 | proxy = url.parse(proxy) | ||
229 | if proxy.user and proxy.password then | ||
230 | lower["proxy-authorization"] = | ||
231 | "Basic " .. (mime.b64(proxy.user .. ":" .. proxy.password)) | ||
232 | end | ||
233 | end | ||
225 | -- override with user headers | 234 | -- override with user headers |
226 | for i,v in base.pairs(reqt.headers or lower) do | 235 | for i,v in base.pairs(reqt.headers or lower) do |
227 | lower[string.lower(i)] = v | 236 | lower[string.lower(i)] = v |