Re: How do I print http 404 not found header?
by Robert Sedlacek » Wed, 20 Oct 2004 01:26:56 GMT
You could first say what you are trying to do. :) If you want to have a
custom ErrorDocument, print out the Data you want to sent to the browser.
And if this is html, a Content-Type set to text/html should be right.
g,
Robert
--
http://www.**--****.com/
sapere aude.
How do I print http 404 not found header?
by nntp » Wed, 20 Oct 2004 01:28:10 GMT
print "HTTP/1.1 404 Not Found";
do I need
print "Content-type: text/html\n\n"; after it?
Should I print
print "HTTP/1.1 404 Not Found";
print "locatioin: ...";
Re: How do I print http 404 not found header?
by lesley_b_linux » Wed, 20 Oct 2004 04:29:48 GMT
Robert Sedlacek < XXXX@XXXXX.COM > writes:
I'd advise against a customised error document. Nimda seized quite a few
servers up because they were sending customised 404 pages out. A simple 404
not found http message left to the browser default display mechanism is
sufficient.
Regards
Lesley
Re: How do I print http 404 not found header?
by Gunnar Hjalmarsson » Wed, 20 Oct 2004 05:38:17 GMT
Nothing is preventing you from doing both, is there?
print "Status: 404 Not Found\n",
"Content-type: text/html; charset=ISO-8859-1\n",
"\n";
--
Gunnar Hjalmarsson
Email: http://www.**--****.com/
Re: How do I print http 404 not found header?
by nntp » Wed, 20 Oct 2004 06:50:31 GMT
>
Do you know where I can find the correct header for 404?
You did
print "Status: 404 Not Found\n",
I did
print "HTTP:/1.1 404 Not Found\n",
I need to fake the header to make the brower think it is 404. The fact is I
am using a script to give the error.
So, when seombody visits at some.cgi?okok, I return a 404 header.
Re: How do I print http 404 not found header?
by Gunnar Hjalmarsson » Wed, 20 Oct 2004 07:06:08 GMT
I thought that "Status: 404" was correct. Actually, I hope it is,
because I'm using it myself for similar purposes. ;-)
Your question is off topic here, and if you want to go into details with
respect to the HTTP specification, this is definitely the wrong place.
--
Gunnar Hjalmarsson
Email: http://www.**--****.com/
Re: How do I print http 404 not found header?
by lesley_b_linux » Wed, 20 Oct 2004 07:38:12 GMT
Gunnar Hjalmarsson < XXXX@XXXXX.COM > writes:
In a totally OT way :
From RFC2616
6.1 Status-Line
The first line of a Response message is the Status-Line, consisting
of the protocol version followed by a numeric status code and its
associated textual phrase, with each element separated by SP
characters. No CR or LF is allowed except in the final CRLF sequence.
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
Not sure about 'HTTP:/1.1' thought it might be 'HTTP/1.1'
Lesley
Re: How do I print http 404 not found header?
by Alan J. Flavell » Wed, 20 Oct 2004 07:46:37 GMT
Surely CGI.pm will take care of such details?
"Status: 404 reason text" is correct for a normal CGI response, but
not for an nph response.
But if, for some reason, your script were to be repurposed as an
nph script, it would have to be re-cast.
Right.
But we have an FAQ which points to better places, and even to
some specifications. So we're not all bad :-}
Re: How do I print http 404 not found header?
by Alan J. Flavell » Wed, 20 Oct 2004 07:52:13 GMT
RFC2616 is *not* a CGI specification.
Re: How do I print http 404 not found header?
by Abigail » Wed, 20 Oct 2004 09:41:59 GMT
nntp ( XXXX@XXXXX.COM ) wrote on MMMMLXVI September MCMXCIII in
{} print "HTTP/1.1 404 Not Found";
{} do I need
{} print "Content-type: text/html\n\n"; after it?
{}
{} Should I print
{} print "HTTP/1.1 404 Not Found";
{} print "locatioin: ...";
Do you actually have a Perl question?
Abigail
--
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'
Re: How do I print http 404 not found header?
by Jgen Exner » Wed, 20 Oct 2004 10:26:36 GMT
No, print() statements in Perl are independent of each other. The first text
will print just fine without the second print() command.
Is there actually any programming language where you would have to issue a
second print command for the first one to print?
Now, if you _want_ to print the second line for your particular application
or not, that is a totally different questions and you should ask in a NG
that actually deals with your kind of application.
jue
Re: How do I print http 404 not found header?
by Jgen Exner » Wed, 20 Oct 2004 10:28:42 GMT
[...]
He did. He wanted to know if in Perl you can use a single print() statement
or if they must come in pairs. Or something like that....
jue
Re: How do I print http 404 not found header?
by lesley_b_linux » Wed, 20 Oct 2004 17:02:53 GMT
"Alan J. Flavell" < XXXX@XXXXX.COM > writes:
Correct, 10 out 10, go to the top of the class :)
It does however happen to specify HTTP responses in Section 6
However if you want a CGI specification the nearest I can offer was a URL
posted in another thread --> http://www.**--****.com/
HTH
Lesley
Re: How do I print http 404 not found header?
by Alan J. Flavell » Wed, 20 Oct 2004 18:59:28 GMT
-?
That's not surprising, since it's the HTTP/1.1 specification.
As the relevant Perl FAQ says, at e.g
http://www.**--****.com/ #What-is-the-correct-form-of-response-from-a-CGI-script-
The similarity between CGI response headers (defined in the CGI
specification) and HTTP response headers (defined in the HTTP
specification, RFC2616) is intentional, but can sometimes be
confusing.
Actually, I prefer the one referenced in the Perl FAQ part 9:
Current best-practice RFC draft at: http://www.**--****.com/
although it never does seem to have quite made it to the
originally-mooted RFC status. Maybe the IETF don't really consider
the CGI interface to be in their parish, but Ken did an excellent
piece of work in collating a best-practice specification, and it seems
to me that it's the best that we've got (the NCSA spec is rather
informal, and leaves many questions unanswered).
U2. :-}
Re: How do I print http 404 not found header?
by Greg Schmidt » Thu, 21 Oct 2004 03:32:48 GMT
Hmm, maybe buffering issues due to the first text not ending with a
newline?
--
Greg Schmidt XXXX@XXXXX.COM
Trawna Publications http://www.**--****.com/