Response codes other than 200 OK



I'm trying to use HTTP::Response to create a response when my perl cgi program is run.

I keep getting "malformed header" errors:
.... malformed header from script. Bad header=HTTP/1.1 304 (Not Modified)

I set all the headers and possible content then finally issue
print $r->as_string();

Where $r is my HTTP::Response item.

So I can see exactly what is sent, I also use sendmail to send that exact thing as an e-mail message.

%mailmsg = (
...
Message => "---\n" . $r-> as_string() . "---\n",
);
sendmail %mailmsg;

and this is what I get in e-mail.... looks OK to me.

---
HTTP/1.1 304 (Not Modified)
Connection: close
Date: Mon, 13 Mar 2006 16:11:49 GMT
Expires: Mon, 10 Apr 2006 16:11:49 GMT


---

How can I return various HTTP result codes to clients? Not everything is "200 OK" simple.

I've tried including content-type: headers too, with no affect.
All I can find on google is to print the content-type header first, followed by a blank line... that woul just make all MY headers part of the response BODY... the clien would see a 200 OK status code. :-(

Thanks,
.



Relevant Pages

  • Re: Newsgroups with large number of posts hangs OE
    ... My response was an unsubtle reference to my frustration with OE's bugs. ... settings in the large NGs I susbscribe to to "headers only" then use the "Sync All" button which then proceeds to d/l all the headers of these large NGs. ... I suppose that could possibly be due to the server of that particular NG.....I dunno. ... The best way to do this is to right click on the folder name in the folder list. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Igor, pAPP toolkit questions
    ... data will result in authorization and the same response at a later ... although this post deals with outgoing stuff and NTLM credentials, ... this using the pAPP toolkit that would be just excellent! ... > headers have been fully prepared. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: Alert box doesnt appear
    ... response which consists of headers and content. ... and provides the location information (in this ... If you want to have a message box and then navigate to the next page, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How could this possibly happen (HttpURLConnection + simple JSP page)
    ... In PHP that would throw some nasty HTTP-related warnings and potentially break the page as you are changing the headers after HTML display? ... You are writing code in a special format that is compiled in to a servlet, which is then executed by the server when the page is requested. ... The other thing is that writing things "after HTML display" is probably very difficult as the display is done on the users computer when they have recieved the response. ... When you create a response for the user it does not necessarily get sent back as soon as you start, and more importantly the headers do not necessarily finish as soon as you start writing to the body. ...
    (comp.lang.java.help)
  • Re: URLScan
    ... Are you using UrlScan to remove or alter the server header in the response? ... of headers at once. ... The symptom you'll seen when any ISAPI filter modifies any ...
    (microsoft.public.inetserver.iis.security)