diff options
author | goodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2000-09-17 17:45:55 +0000 |
---|---|---|
committer | goodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2000-09-17 17:45:55 +0000 |
commit | 7d29b42986d5c0af3846831923b52d36e310d8c1 (patch) | |
tree | c2cfb7353e75b8c9197ac76a57e3b4b2f6a08a37 /src/Content.c | |
parent | 1a0181be55245253fd16000387fdfc50eb05c1e9 (diff) |
Added a function for sending data from an open file descriptor down
the socket.
Tom
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@39 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Content.c')
-rw-r--r-- | src/Content.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Content.c b/src/Content.c index 2f22bac..da1139b 100644 --- a/src/Content.c +++ b/src/Content.c @@ -1292,3 +1292,38 @@ static int ControlTerminationPage(cGH *cctkGH, httpRequest *request) return retval; } + + /*@@ + @routine HTTP_ContentSendFromFile + @date Sun Sep 17 17:35:57 2000 + @author Tom Goodale + @desc + Reads data from the filedescriptor and sends it to the HTTP request. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +int HTTP_ContentSendFromFile(httpRequest *request, int filedes) +{ + int bytes_sent; + int n_bytes; + char buffer[4096]; + + bytes_sent = 0; + while((n_bytes = read(filedes, buffer,4096)) > 0) + { + HTTP_Write(request, buffer, n_bytes); + bytes_sent += n_bytes; + } + + if(n_bytes == -1) + { + bytes_sent = -bytes_sent; + } + + return bytes_sent; +} |