[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Http request chunked problem
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Mon, 5 Sep 2011 16:13:11 -0700
On Friday 02, ersin ersin wrote:
> Hey,
>
> I have already asked this same problem in the lua irc channel, with no
> success.
>
> Well the problem is, when I use a transfer-encoding in my http.request my
> http.request takes much much longer then normally. I have tried couple of
> things with the same effect. I really don't know how to fix this.
>
> This is my source code I am using at the moment:
>
> require"luarocks.require"
>
> local socket = require("socket")
> local http = require("socket.http")
> local ltn12 = require("ltn12")
>
> data = 'Message'
>
> r, c, h = http.request {
> headers = {
> ["Content-Type"] = "text/plain",
> ["Transfer-Encoding"] = 'chunked',
> },
>
> method = "PUT",
> url = "http://127.0.0.1/handler/",
> source = ltn12.source.string(data)
> }
The HTTP server should be closing the connection once the last "zero-length"
chunk is sent. You should check which side is closing the socket (i.e. use
tcpdump or wireshark). You should also check if the server is first
responding with status "100 Continue.", it shouldn't since LuaSocket doesn't
send the "Expect: 100-continue" header.
You could also try the http client library in my lua-handlers [1] project. I
have uploaded a http client PUT example [2], that does the same thing as your
code.
1. https://github.com/Neopallium/lua-handlers
2. https://github.com/Neopallium/lua-
handlers/blob/master/examples/http_client_put.lua
--
Robert G. Jakabosky