diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-25 05:27:44 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-25 05:27:44 +0000 |
| commit | 888496aa821cd09d925046250ea98b1512293fd5 (patch) | |
| tree | 217e2b532762a64b58c4fffcb2cba08ba2243462 /src/http.lua | |
| parent | 4fc164b8eaa0453050a0a859321c327bb2c4f776 (diff) | |
| download | luasocket-888496aa821cd09d925046250ea98b1512293fd5.tar.gz luasocket-888496aa821cd09d925046250ea98b1512293fd5.tar.bz2 luasocket-888496aa821cd09d925046250ea98b1512293fd5.zip | |
FTP low-level working.
SMTP connection oriented working.
ltn12 improved.
Diffstat (limited to 'src/http.lua')
| -rw-r--r-- | src/http.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/http.lua b/src/http.lua index da18aaf..f787b9d 100644 --- a/src/http.lua +++ b/src/http.lua | |||
| @@ -68,7 +68,7 @@ end | |||
| 68 | 68 | ||
| 69 | local function receive_body(reqt, respt, tmp) | 69 | local function receive_body(reqt, respt, tmp) |
| 70 | local sink = reqt.sink or ltn12.sink.null() | 70 | local sink = reqt.sink or ltn12.sink.null() |
| 71 | local pump = reqt.pump or ltn12.pump | 71 | local step = reqt.step or ltn12.pump.step |
| 72 | local source | 72 | local source |
| 73 | local te = respt.headers["transfer-encoding"] | 73 | local te = respt.headers["transfer-encoding"] |
| 74 | if te and te ~= "identity" then | 74 | if te and te ~= "identity" then |
| @@ -80,9 +80,9 @@ local function receive_body(reqt, respt, tmp) | |||
| 80 | source = socket.source("by-length", tmp.sock, length) | 80 | source = socket.source("by-length", tmp.sock, length) |
| 81 | else | 81 | else |
| 82 | -- get it all until connection closes | 82 | -- get it all until connection closes |
| 83 | source = socket.source("until-closed", tmp.sock) | 83 | source = socket.source(tmp.sock) |
| 84 | end | 84 | end |
| 85 | socket.try(pump(source, sink)) | 85 | socket.try(ltn12.pump.all(source, sink, step)) |
| 86 | end | 86 | end |
| 87 | 87 | ||
| 88 | local function send_headers(sock, headers) | 88 | local function send_headers(sock, headers) |
| @@ -125,7 +125,7 @@ end | |||
| 125 | local function send_request(reqt, respt, tmp) | 125 | local function send_request(reqt, respt, tmp) |
| 126 | local uri = request_uri(reqt, respt, tmp) | 126 | local uri = request_uri(reqt, respt, tmp) |
| 127 | local headers = tmp.headers | 127 | local headers = tmp.headers |
| 128 | local pump = reqt.pump or ltn12.pump | 128 | local step = reqt.step or ltn12.pump.step |
| 129 | -- send request line | 129 | -- send request line |
| 130 | socket.try(tmp.sock:send((reqt.method or "GET") | 130 | socket.try(tmp.sock:send((reqt.method or "GET") |
| 131 | .. " " .. uri .. " HTTP/1.1\r\n")) | 131 | .. " " .. uri .. " HTTP/1.1\r\n")) |
| @@ -136,9 +136,11 @@ local function send_request(reqt, respt, tmp) | |||
| 136 | -- send request message body, if any | 136 | -- send request message body, if any |
| 137 | if not reqt.source then return end | 137 | if not reqt.source then return end |
| 138 | if headers["content-length"] then | 138 | if headers["content-length"] then |
| 139 | socket.try(pump(reqt.source, socket.sink(tmp.sock))) | 139 | socket.try(ltn12.pump.all(reqt.source, |
| 140 | socket.sink(tmp.sock), step)) | ||
| 140 | else | 141 | else |
| 141 | socket.try(pump(reqt.source, socket.sink("http-chunked", tmp.sock))) | 142 | socket.try(ltn12.pump.all(reqt.source, |
| 143 | socket.sink("http-chunked", tmp.sock), step)) | ||
| 142 | end | 144 | end |
| 143 | end | 145 | end |
| 144 | 146 | ||
