diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-08-31 00:58:07 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-08-31 00:58:07 +0000 |
| commit | 6789b83ff5c15296267f880d3b98cf8a1800c30a (patch) | |
| tree | 9571dc81cb0147218332cda34b7ccdfed37ddbbc /src/ftp.lua | |
| parent | c51d4acf1c2a8675a3bb043e799ff4390cef47d6 (diff) | |
| download | luasocket-6789b83ff5c15296267f880d3b98cf8a1800c30a.tar.gz luasocket-6789b83ff5c15296267f880d3b98cf8a1800c30a.tar.bz2 luasocket-6789b83ff5c15296267f880d3b98cf8a1800c30a.zip | |
Starting to use RCS in princeton again. Not behind a firewall anymore.
Diffstat (limited to 'src/ftp.lua')
| -rw-r--r-- | src/ftp.lua | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ftp.lua b/src/ftp.lua index 25226a6..bfc4ece 100644 --- a/src/ftp.lua +++ b/src/ftp.lua | |||
| @@ -602,10 +602,12 @@ function Public.put_cb(request) | |||
| 602 | local control, err = Private.open(parsed) | 602 | local control, err = Private.open(parsed) |
| 603 | if not control then return err end | 603 | if not control then return err end |
| 604 | local segment = Private.parse_path(parsed) | 604 | local segment = Private.parse_path(parsed) |
| 605 | return Private.change_dir(control, segment) or | 605 | err = Private.change_dir(control, segment) or |
| 606 | Private.change_type(control, parsed.params) or | 606 | Private.change_type(control, parsed.params) or |
| 607 | Private.upload(control, request, segment) or | 607 | Private.upload(control, request, segment) or |
| 608 | Private.close(control) | 608 | Private.close(control) |
| 609 | if err then return nil, err | ||
| 610 | else return 1 end | ||
| 609 | end | 611 | end |
| 610 | 612 | ||
| 611 | ----------------------------------------------------------------------------- | 613 | ----------------------------------------------------------------------------- |
| @@ -616,15 +618,15 @@ end | |||
| 616 | -- type: "i" for "image" mode, "a" for "ascii" mode or "d" for directory | 618 | -- type: "i" for "image" mode, "a" for "ascii" mode or "d" for directory |
| 617 | -- user: account user name | 619 | -- user: account user name |
| 618 | -- password: account password) | 620 | -- password: account password) |
| 621 | -- content: file contents | ||
| 619 | -- content: file contents | 622 | -- content: file contents |
| 620 | -- Returns | 623 | -- Returns |
| 621 | -- err: error message if any | 624 | -- err: error message if any |
| 622 | ----------------------------------------------------------------------------- | 625 | ----------------------------------------------------------------------------- |
| 623 | function Public.put(url_or_request, content) | 626 | function Public.put(url_or_request, content) |
| 624 | local request = Private.build_request(url_or_request) | 627 | local request = Private.build_request(url_or_request) |
| 625 | request.content_cb = function() | 628 | request.content = request.content or content |
| 626 | return content, string.len(content) | 629 | request.content_cb = socket.callback.send_string(request.content) |
| 627 | end | ||
| 628 | return Public.put_cb(request) | 630 | return Public.put_cb(request) |
| 629 | end | 631 | end |
| 630 | 632 | ||
| @@ -641,12 +643,9 @@ end | |||
| 641 | -- err: error message in case of error, nil otherwise | 643 | -- err: error message in case of error, nil otherwise |
| 642 | ----------------------------------------------------------------------------- | 644 | ----------------------------------------------------------------------------- |
| 643 | function Public.get(url_or_request) | 645 | function Public.get(url_or_request) |
| 644 | local cat = socket.concat.create() | 646 | local concat = socket.concat.create() |
| 645 | local request = Private.build_request(url_or_request) | 647 | local request = Private.build_request(url_or_request) |
| 646 | request.content_cb = function(chunk, err) | 648 | request.content_cb = socket.callback.receive_concat(concat) |
| 647 | if chunk then cat:addstring(chunk) end | ||
| 648 | return 1 | ||
| 649 | end | ||
| 650 | local err = Public.get_cb(request) | 649 | local err = Public.get_cb(request) |
| 651 | return cat:getresult(), err | 650 | return concat:getresult(), err |
| 652 | end | 651 | end |
