Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

http 404 header

 [1/10] from: hallvard:ystad:helpinhand at: 2-Jan-2003 23:26


Hi I try to read a customized error message from a web page, and here's what I get:
>> trace/net on >> t: read http://helpinhand.com/nonexistant.html
URL Parse: none none helpinhand.com none none nonexistant.html Net-log: ["Opening tcp for" HTTP] connecting to: helpinhand.com Net-log: {GET /nonexistant.html HTTP/1.0 Accept: */* Connection: close User-Agent: REBOL 2.5.0.3.1 Host: helpinhand.com } Net-log: "HTTP/1.1 404 Not Found" ** User Error: Error. Target url: http://helpinhand.com/nonexistant.html coul d not be retrieved. Server response: HTTP/1.1 404 Not Found ** Near: t: read http://helpinhand.com/nonexistant.html Why do I not get the contents? After all, an HTML document _is_ written out! Is this bug fixed in the new betas? Oh, and here's a second question: When I try to redirect from a rebol cgi script (using http headers), I am allowed to write the Location: header, but not the first header, the "HTTP/1.1 200 OK" thing. Or "HTTP/1.1 302 Moved". My web server then reports an error. So I suspect a double header is written out in that case, meaning that rebol automatically writes out a 200 message (I may very well be mistaken here). Am I right in suspecting so? Can this be prevented? In some cases, I'd like to control much of this myself. Regards, ~H

 [2/10] from: gchiu::compkarori::co::nz at: 3-Jan-2003 12:02


On Thu, 02 Jan 2003 23:26:10 +0100 Hallvard Ystad <[hallvard--ystad--helpinhand--com]> wrote:
>Oh, and here's a second question: >When I try to redirect from a rebol cgi script (using >http headers), I am allowed to write the Location: >header, but not the first header, the "HTTP/1.1 200 OK" >thing. Or "HTTP/1.1 302 Moved". My web server then >reports an error. So I suspect a double header is written
I don't think you can do this as your cgi script is executed by the ISP's webserver. To send out server headers correctly, you need to run your own webserver. Perhaps run a rebol cgi script to serve on a different port ... and if your ISP will permit this. -- Graham Chiu

 [3/10] from: al:bri:xtra at: 3-Jan-2003 13:06


Graham wrote:
> Hallvard Ystad <[hallvard--ystad--helpinhand--com]> wrote: > >Oh, and here's a second question: > >When I try to redirect from a rebol cgi script (using http headers), I am
allowed to write the Location: header, but not the first header, the HTTP/1.1 200 OK thing. Or "HTTP/1.1 302 Moved". My web server then reports an error. So I suspect a double header is written
> I don't think you can do this as your cgi script is executed by the ISP's
webserver. To send out server headers correctly, you need to run your own webserver. Perhaps run a rebol cgi script to serve on a different port ... and if your ISP will permit this. Actually you can get Rebol to send out CGI redirects, at least with Xitami and with the microsoft web server (I've forgotten it's name). My %Wiki.r script does this regularly, with this little function: See-Other: func [URL [url!]] [ print rejoin [ Rebol/options/cgi/server-protocol " 303 See Other" newline "Location: " URL newline ] quit ] And I use something like thi: See-Other join Script_URL join Folder Page I'm not entirely sure of the header number; I'm using 303 and it seems to work OK for me. Is 302 or 303 a better chooice? Andrew Martin ICQ: 26227169 http://valley.150m.com/

 [4/10] from: sunandadh:aol at: 2-Jan-2003 19:09


Hallvard :> Why do I not get the contents? After all, an HTML document _is_ written out!
> Is this bug fixed in the new betas?
It's the same in the new betas. It looks like an error to me -- why not submit to feedback? Rebol should distinguish a 404 error that supplies an Error Document (because the website has handled the problem by supplying a default) from a 404 that doesn't. Deep within the HTTP processing, Rebol has this action list: response-actions: [ 100 continue-post 200 success 201 success 204 success 206 success 300 forward 301 forward 302 forward 304 success 407 proxyauth ] It looks to me like it needs to handle 404s more subtly, Sunanda.

 [5/10] from: hallvard:ystad:helpinhand at: 3-Jan-2003 9:48


Thanks, Andrew. I knew this could be done, because I've done it with perl. (The Helpinhand server runs Apache). I know the difference is subtle, I suppose it doesn't even make any difference, but I do distinguish a 301 Moved Permanently from a 303 See Other. In most cases, it's OK for rebol to do this for me. But when I write a Location: header and rebol has already written a "200 OK", the result is non-compliant to the HTTP standard, and I dislike that (even though most browsers seem to redirect in that case. Hm.) Anyway, thanks for the code. ~H Dixit Andrew Martin (01.06 03.01.2003):

 [6/10] from: hallvard:ystad:helpinhand at: 3-Jan-2003 10:25


But it still doesn't work. Darn! From the apache error log: malformed header from script. Bad header=HTTP/1.1 303 See Other Hm. ~H Dixit Hallvard Ystad (09.48 03.01.2003):

 [7/10] from: andreas:bolka:gmx at: 3-Jan-2003 20:29


Thursday, January 2, 2003, 11:26:10 PM, Hallvard wrote:
> Oh, and here's a second question: > When I try to redirect from a rebol cgi script (using http headers),
<<quoted lines omitted: 5>>
> suspecting so? Can this be prevented? In some cases, I'd like to > control much of this myself.
A quick look at the CGI spec solves this mystery - the "Status" header allows you to set the HTTP response status code from within a CGI environment: http-redir: func [url] [ prin rejoin [ "Status: 302 Moved temporarily" newline "Location: " url newline newline ] quit ] -- Best regards, Andreas mailto:[andreas--bolka--gmx--net]

 [8/10] from: al:bri:xtra at: 4-Jan-2003 11:38


Hallvard wrote:
> But it still doesn't work. Darn! > From the apache error log: > malformed header from script. Bad header=HTTP/1.1 303 See Other
After a little experimentation with Rebol as the "browser", I found that 302 Found works better for me than 303 See Other (thanks to Andrea!). Found: func [URL [url!]] [ print rejoin [ Rebol/options/cgi/server-protocol " 302 Found" newline "Location: " URL newline ] quit ] And I still can't see Rebol sending multiple headers. I think there might be something wong with your Apache set up for CGI? Andrew Martin ICQ: 26227169 http://valley.150m.com/

 [9/10] from: al:bri:xtra at: 4-Jan-2003 12:39


> 302 Found works better for me than 303 See Other (thanks to Andrea!).
Sorry. Thank you to Andreas. Andrew Martin Name-Challenged Rebolutionary... ICQ: 26227169 http://valley.150m.com/

 [10/10] from: hallvard:ystad:helpinhand at: 4-Jan-2003 14:54


That's it, Andreas! Status: was the keyword. Everything now works perfectly well. Thanks. Andrew, if you need to see the difference between 300, 301, 302 and 303, you could always look at ftp://ftp.isi.edu/in-notes/rfc2616.txt. ~H Dixit Andreas Bolka (20.29 03.01.2003):

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted