How? Read HTTP message body
[1/5] from: dave:jtgoodstuff at: 10-Aug-2001 19:23
I'm totally new to Rebol. I'm modifying the webserver.r script from the Rebol script library. I've stripped it down. The technique that was used seems to make available the Request Line and Message Headers.Which are line oriented. It seems to stop after it hits the blank line and the actual Message Body is missing. Here's the main code. Any hints on how to get to the message body? Oh yes, what's the [err] for on send-cmd? I can't get rid of it but it doesn't appear to do anything. Thanks. cntr: 1 buffer: make string! 1024 ; will auto-expand if needed listen-port: open/lines tcp://:9090 ; port used for web connections send-cmd: function [buffer thecntr] [err] [ insert http-port join "HTTP/1.0 200 OK^/" [ "Content-type: text/html^/^/" "<br><pre>" buffer "</pre><br>" length? buffer "<br><br>" now/time " " thecntr ] ] forever [ http-port: first wait listen-port clear buffer while [not empty? request: first http-port] [ repend buffer [request newline] ] set 'cntr cntr + 1 send-cmd buffer cntr close http-port ]
[2/5] from: arolls:bigpond:au at: 11-Aug-2001 13:12
Re: How? Read HTTP message body - err
> Oh yes, what's the [err] for on send-cmd? I can't get rid of it > but it doesn't appear to do anything.
<<quoted lines omitted: 7>>> ] > ]
The first argument to the 'function function is a block of user supplied arguments. In this case, it is: [buffer thecntr]. The second argument is a block of local words to use in the body of the function. In this case, it is: [err]. Since we can see that 'err is not used in the body, we can remove it, but we still require a block here, so replace it with an empty block; . The third argument is the body, of course. This is the change: send-cmd: function [buffer thecntr] [err] [...] send-cmd: function [buffer thecntr]  [...]
>> ? function
USAGE: FUNCTION spec vars body DESCRIPTION: Defines a user function with local words. FUNCTION is a function value. ARGUMENTS: spec -- Optional help info followed by arg words (and optional type and string) (Type: block) vars -- List of words that are local to the function (Type: block) body -- The body block of the function (Type: block) 'function works slightly differently to 'func. You could rewrite it using 'func: send-cmd: func [buffer thecntr /local err][...] or even better, with comments that document what it does properly. send-cmd: func ["I am a function that does something" buffer "Your preformatted text" thecntr "counter" /local err "not used at the moment" ][ ... ]
[3/5] from: tserpa:biomedsys at: 11-Aug-2001 6:37
Or you could just change function to func Ted
[4/5] from: dave::jtgoodstuff::com at: 11-Aug-2001 9:16
Thank you Anton, you explaned that well..
[5/5] from: tserpa::elwellinc::com at: 11-Aug-2001 1:40
How? Read HTTP message body
Sorry, Anton. I stopped reading your reply to early. Ted
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted