Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ Programming
➜ General
➜ Lua compiler for windows
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #15 on Tue 22 Jan 2008 01:08 AM (UTC) |
| Message
| Well I don't know about that. I used tcpdump to dump a session using LuaSocket between MUSHclient and my home web server (asking for the root document) and this is what it generated:
GET / HTTP/1.1
host: 10.0.0.2
te: trailers
connection: close, TE
user-agent: LuaSocket 2.0.1
The only problem I can see here is the user-agent, so a custom query using some other agent may well get through. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Isthiriel
(113 posts) Bio
|
| Date
| Reply #16 on Tue 22 Jan 2008 01:46 AM (UTC) Amended on Tue 22 Jan 2008 02:05 AM (UTC) by Isthiriel
|
| Message
| ... other than "Host" != "host". Sure.
GET /<query-string> HTTP/1.1
host: api.eve-online.com
fails.
So that's the problem there. LuaSocket isn't generating a Host header. (Which means it's technically not generating a HTTP/1.1 compliant request either. It is, instead, generating a bunch of garbage 'host', 'te' ... headers. And 'user-agent' != 'User-Agent' either.)
Nvm. It turns out that header field names are supposed to be case-insensitive. Which means that, since CCP is a MS shop, the fault probably lies with IIS. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #17 on Tue 22 Jan 2008 02:37 AM (UTC) Amended on Wed 23 Jan 2008 05:51 AM (UTC) by Nick Gammon
|
| Message
| Well I got it to work in the end, thanks to Isthiriel and my own debugging with Wireshark. :)
If you edit the file http.lua in the "socket" directory under the MUSHclient directory, you will find the spot where they use lower-case header names. Amend the table to capitalize them, and then the request works:
local function adjustheaders(reqt)
-- default headers
local lower = {
["User-Agent"] = USERAGENT,
["Host"] = reqt.host,
["Connection"] = "close, TE",
["Te"] = "trailers"
}
-- if we have authentication information, pass it along
if reqt.user and reqt.password then
lower["Authorization"] =
"Basic " .. (mime.b64(reqt.user .. ":" .. reqt.password))
end
-- override with user headers
for i,v in base.pairs(reqt.headers or lower) do
lower[string.lower(i)] = v
end
return lower
end
Edited to change User-agent to User-Agent. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #18 on Tue 22 Jan 2008 02:45 AM (UTC) Amended on Tue 22 Jan 2008 02:50 AM (UTC) by Nick Gammon
|
| Message
| I agree with Isthiriel that they (Eve Online, not Luasocket) have incorrectly implemented the HTTP specification. From RFC 2616 section 4.2 we see:
Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.
At one stage I got this back from the Eve web site:
<h1>Bad Request (Invalid Header Name)</h1>
A more general solution would be to change (as well) the code I quoted above, where it has this part:
-- override with user headers
for i,v in base.pairs(reqt.headers or lower) do
lower[string.lower(i)] = v
end
Even if you specify your own header, it is forced into lower case, which doesn't help. I initially tried to put a "Host" header into the user-supplied header table.
You would need to change string.lower(i) into a capitalization function. Such a function could be:
function capitalize (s)
return string.upper (string.sub (s, 1, 1)) .. string.sub (s, 2)
end -- capitalize
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Isthiriel
(113 posts) Bio
|
| Date
| Reply #19 on Tue 22 Jan 2008 03:02 AM (UTC) |
| Message
| Canonically, TE and User-Agent shouldn't be first-letter capital, rest lower either.
I've complained about CCP's code monkeys before (on their forums) but in this case I think it almost has to be IIS doing something wrong rather than the ASP written by CCP's web cell. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #20 on Tue 22 Jan 2008 04:09 AM (UTC) |
| Message
| I think it is slightly annoying that Luasocket uses all lowercase. Although the spec says the case is irrelevant, most of the examples I have seen have had the words capitalized. For example:
http://en.wikipedia.org/wiki/HTTP
And you are right, they show (by example) both words capitalized, as in "Content-Length".
I think there are quite a few programmers that skip reading the specs, and code from examples, and thus they probably thought that a case-sensitive match was OK, and indeed was compatible with most browsers.
The utility Wireshark helped me in my debugging, see here:
http://www.wireshark.org/
This is a GPL utility (that is, free) that analyzes network traffic. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Metsuro
USA (389 posts) Bio
|
| Date
| Reply #21 on Tue 22 Jan 2008 04:19 AM (UTC) |
| Message
| | so by changing the suggested portions you got luasocket to behave correctly? and are saying that even with it behaving correctly you still wouldn't get the expect items from CCP? |
Everything turns around in the end | | Top |
|
| Posted by
| Metsuro
USA (389 posts) Bio
|
| Date
| Reply #22 on Tue 22 Jan 2008 04:45 AM (UTC) Amended on Tue 22 Jan 2008 04:50 AM (UTC) by Metsuro
|
| Message
| ok well you know I added the changes... thank you very much by the way... but i couldn't seem to get the information still so i figured it was just not gonna work... but then i tried to access the address again.. and got a loading problem page... so i guess it was just down and then just a moment ago i got what I was looking for so thank you. Now to move on the next step figuring out how to parse the xml... there any good books or reference manuals?
|
Everything turns around in the end | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #23 on Tue 22 Jan 2008 05:41 AM (UTC) |
| Message
| Well this is your lucky day because MUSHclient has a built-in XML parser (if you want to use it).
This test demonstrates how it can parse the XML into a Lua table:
xml = [[
<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2008-01-22 03:35:07</currentTime>
<result>
<characterID>1097517373</characterID>
<name>Nikolai Wolfwood</name>
<race>Caldari</race>
<bloodLine>Civire</bloodLine>
<gender>Male</gender>
<corporationName>Knights of Minas Tirith</corporationName>
<corporationID>1696815543</corporationID>
<balance>102059730.45</balance>
<attributeEnhancers>
<willpowerBonus>
<augmentatorName>Neural Boost - Basic</augmentatorName>
<augmentatorValue>3</augmentatorValue>
</willpowerBonus>
<memoryBonus>
<augmentatorName>Memory Augmentation - Basic</augmentatorName>
<augmentatorValue>3</augmentatorValue>
</memoryBonus>
<charismaBonus>
<augmentatorName>Social Adaptation Chip - Basic</augmentatorName>
<augmentatorValue>3</augmentatorValue>
</charismaBonus>
<perceptionBonus>
<augmentatorName>Ocular Filter - Basic</augmentatorName>
<augmentatorValue>3</augmentatorValue>
</perceptionBonus>
<intelligenceBonus>
<augmentatorName>Cybernetic Subprocessor - Basic</augmentatorName>
<augmentatorValue>3</augmentatorValue>
</intelligenceBonus>
</attributeEnhancers>
<attributes>
<intelligence>7</intelligence>
<memory>9</memory>
<charisma>6</charisma>
<perception>10</perception>
<willpower>7</willpower>
</attributes>
<rowset name="skills" key="typeID" columns="typeID,skillpoints,level,unpublished">
<row typeID="11584" skillpoints="12" level="0" />
<row typeID="3427" skillpoints="2829" level="2" />
<row typeID="3426" skillpoints="8016" level="3" />
<row typeID="3432" skillpoints="1581" level="1" />
<row typeID="3551" skillpoints="8000" level="3" />
<row typeID="3424" skillpoints="90510" level="4" />
<row typeID="3417" skillpoints="1415" level="2" />
<row typeID="3413" skillpoints="45255" level="4" />
<row typeID="21059" skillpoints="2829" level="2" />
<row typeID="3422" skillpoints="90510" level="4" />
<row typeID="3416" skillpoints="8000" level="3" />
<row typeID="3425" skillpoints="16000" level="3" />
<row typeID="3420" skillpoints="32000" level="3" />
<row typeID="3300" skillpoints="8000" level="3" />
<row typeID="3304" skillpoints="4243" level="2" />
<row typeID="3312" skillpoints="2829" level="2" />
<row typeID="3310" skillpoints="2829" level="2" />
<row typeID="3311" skillpoints="2829" level="2" />
<row typeID="3301" skillpoints="8000" level="3" />
<row typeID="3318" skillpoints="90510" level="4" />
<row typeID="3386" skillpoints="250" level="1" />
<row typeID="3377" skillpoints="45255" level="4" />
<row typeID="12385" skillpoints="77040" level="3" />
<row typeID="3378" skillpoints="45255" level="4" />
<row typeID="3375" skillpoints="45255" level="4" />
<row typeID="3374" skillpoints="45255" level="4" />
<row typeID="12376" skillpoints="24000" level="3" />
<row typeID="3379" skillpoints="41507" level="3" />
<row typeID="3392" skillpoints="45255" level="4" />
<row typeID="25863" skillpoints="750" level="1" />
<row typeID="3323" skillpoints="2829" level="2" />
<row typeID="12441" skillpoints="512000" level="5" />
<row typeID="3319" skillpoints="8000" level="3" />
<row typeID="3320" skillpoints="250" level="1" />
<row typeID="3321" skillpoints="500" level="1" />
<row typeID="3450" skillpoints="250" level="1" />
<row typeID="3449" skillpoints="250" level="1" />
<row typeID="3455" skillpoints="250" level="1" />
<row typeID="3411" skillpoints="750" level="1" />
<row typeID="3402" skillpoints="8000" level="3" />
<row typeID="3356" skillpoints="2829" level="2" />
<row typeID="3355" skillpoints="1415" level="2" />
<row typeID="12099" skillpoints="1500" level="1" />
<row typeID="3334" skillpoints="64435" level="3" />
<row typeID="3330" skillpoints="93019" level="4" />
<row typeID="3342" skillpoints="1000" level="1" />
<row typeID="12097" skillpoints="500" level="1" />
<row typeID="3327" skillpoints="45255" level="4" />
</rowset>
</result>
<cachedUntil>2008-01-22 04:35:07</cachedUntil>
</eveapi>
]]
t = assert (utils.xmlread (xml))
require "tprint"
tprint (t)
Now you may not want to use MUSHclient to parse it, I think the Lua manual has an example of an XML parser as well.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
94,017 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top