[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to authenticate against the proxy with socket.http [SOLVED!]
- From: "J.Jørgen von Bargen" <jjvb.primus@...>
- Date: Wed, 17 Mar 2010 18:33:19 +0100
Hi folks
>>> LuaSocket just has no http proxy auth impl.
>> the http module is written in lua, so just change the source if you
want that.
> Yes, I know and I'm also willing to try, but I was just asking, if
> someone already did it. (I'm just lazy and I've got enough more
> important things to do :-) )
Well, now I did it for myself. After taking a deep look into socket.http
it really turned out to be quite simple:
In the function adjustheaders I've added a few lines:
-- if we have proxy-authentication information, make a header entry
for this
local proxy = reqt.proxy or PROXY
if proxy then
proxy = url.parse(proxy)
if proxy.user and proxy.password then
lower["proxy-authorization"] =
"Basic " .. (mime.b64(proxy.user ..
":" .. proxy.password))
end
end
just before
-- if we have authentication information, pass it along
and thats all. After fixing my test script to
local http = require("socket.http")
http.PROXY="http://username:password@proxyhost:8080/"
local a,b,c,d=http.request("http://www.example.com/")
I managed to pass through our proxy. I'd suggest to add this block to
the socket.http in the socket library, as it will do no harm to existing
code
Regards Jørgen