Subject: | [PATCH] Documentation - content-type header |
Could I suggest the attached patch for the documentation please? I spent
a while searching the internet for the best way to add a content-type
header; seeing as everyone will almost certainly want to do this, I
think an example would be good in the main documentation.
Many thanks.
Subject: | content.patch |
diff -rupN libwww-perl-5.837/lib/HTTP/Daemon.pm libwww-perl-5.837-andy/lib/HTTP/Daemon.pm
--- libwww-perl-5.837/lib/HTTP/Daemon.pm 2009-06-15 19:24:38.000000000 +0100
+++ libwww-perl-5.837-andy/lib/HTTP/Daemon.pm 2012-12-29 00:28:32.302856296 +0000
@@ -630,6 +630,10 @@ HTTP::Daemon - a simple http server clas
# remember, this is *not* recommended practice :-)
$c->send_file_response("/etc/passwd");
}
+ elsif ($r->method eq 'GET' and $r->uri->path eq "/image.jpeg") {
+ $c->send_response('Content-Type: image/jpeg');
+ $c->send_file_response("image.jpeg");
+ }
else {
$c->send_error(RC_FORBIDDEN)
}
@@ -849,6 +853,11 @@ client as the response content. The rou
return an undefined or empty value. If the client is HTTP/1.1 aware
then we will use chunked transfer encoding for the response.
+example:
+
+ # Set the MIME content-type
+ $c->send_response('Content-Type: text/html');
+
=item $c->send_redirect( $loc )
=item $c->send_redirect( $loc, $code )