Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http GET not working on luasocket 3.0 #102

Closed
aryajur opened this issue Jul 12, 2014 · 7 comments
Closed

http GET not working on luasocket 3.0 #102

aryajur opened this issue Jul 12, 2014 · 7 comments

Comments

@aryajur
Copy link

aryajur commented Jul 12, 2014

Hi,
If I do the following:

local h = require "socket.http"
print(h.request([[http://www.amved.com/milindsweb/tableDB.html]]))

It prints the correct HTML if I use luasocket 2.0 but if I use luasocket 3.0 it prints out this:

<!-- pageok -->
<!-- managed by puppet -->
<html>
<pre>pageok</pre>
</html>

200 table: 0092BD00 HTTP/1.1 200 OK

Is this a bug or something needs to be done differently?

@diegonehab
Copy link
Contributor

I believe this is a bug on the server side.
For some reason, it is not accepting the port in the Host request header
Host: www.amved.com:80
If you remove the port, it works fine.
There is no reason why it should fail in this case.
Something fishy must be going on.

@aryajur
Copy link
Author

aryajur commented Jul 15, 2014

So luasocket 2.0 did not send the port number with the host name? Just curious why it would work there? Also are there benefits to adding the port number in the host name?

Thanks.

@catwell
Copy link
Member

catwell commented Jul 15, 2014

@aryajur See #74

I didn't expect to break some Web servers here. No idea what the cleanest fix would be.

I was using RFC2616 as a reference, now RFC7230 came out to clarify things. It looks like the host header should be exactly what was specified in the authority part of the URI.

@diegonehab
Copy link
Contributor

Seems like the correct line in the adjustheaders() function is
local host = string.gsub(reqt.authority, "^.-@", "")

@catwell
Copy link
Member

catwell commented Jul 15, 2014

Something like that. But we must make sure we have reqt.authority correctly defined at this point in every case (is this the case?).

@diegonehab
Copy link
Contributor

It would take a request with an empty host to break this code. This would trigger an error earlier on, in adjustheaders().

@aryajur
Copy link
Author

aryajur commented Jul 16, 2014

With the recent edit to http.lua the problem is not happenning anymore. Thanks.

@aryajur aryajur closed this as completed Jul 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants