0

I am running a Lua HTTP client and the request leads to an error 400:

[root]# ./luatest
<!DOCTYPE HTML><html><head><title>400 Bad Request</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link href="/imgs/errors.css" rel="stylesheet" type="text/css"></head>
<body><h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.</p></body></html> 400     table: 0x1ba1f70        HTTP/1.1 400 Bad Request

[root]# cat luatest
#!/usr/bin/lua
local http = require("socket.http")
print(http.request("http://localhost/"))

[root]# curl "http://localhost"
<html> hi there </html> [root]# 

G-WAN responds correctly to the curl client request, but it dies when requesting the same document from lua. Is there something we're missing, or is this just not going to work?

Gil
  • 3,279
  • 1
  • 15
  • 25
  • Something like [fiddler](http://fiddler2.com/) may help you out here by letting you observe the differences in the raw http requests between curl and gwan. – Mike Jul 18 '13 at 13:25
  • Mike, here G-WAN is the server and curl is the client so G-WAN does not issue any request that could be "compared" to curl's: G-WAN sends a reply to the curl or lua client requests. – Gil Jul 19 '13 at 14:06

2 Answers2

0

Maybe you could have a look at the client HTTP request, and dump it there. If you do not see what's wrong with it, we will have a chance to tell you.

Since 2009, G-WAN understands the HTTP requests of all Web browsers and many clients like cURL, wget, etc. so this client issue is likely to be related to a trivial HTTP syntax comformance issue (like missing the "Host" header with HTTP/1.1).


Since there's obvious confusions in the comments and in the question, here is some clarification:

  • The Lua and curl clients send HTTP requests to G-WAN, the HTTP server
  • use G-WAN -t to log the client requests in the gwan/trace file
  • compare the curl and lua HTTP requests logged in gwan/trace to see what Lua is doing wrong.

That procedure should let you find what's missing in your scenario.

A last thing, G-WAN does not "die": rather, it replies with an HTTP 400 error ("malformed request").

Gil
  • 3,279
  • 1
  • 15
  • 25
  • The developer using the Lua client said it looks like it had something to do with the request being chunked... Trying to get him to get me the sample code of working/non-working... – Derrick Bradbury Jul 19 '13 at 02:42
  • The *"request being chunked"*? Only **HTTP POST and PUT entities** can be chuncked, but NOT the request itself. – Gil Jul 19 '13 at 14:04
  • Still Waiting for him to get back.. that was his comment, I'm trying to get what he did to verify what is happening.... – Derrick Bradbury Jul 22 '13 at 19:41
0

Needed to modify the LUA Request to include proper headers. Developer that did this seems to drop off the face of the earth. Will update if I ever get code from him.