From a9b7dce104b2fc1234d591010f67f217c6287a0d Mon Sep 17 00:00:00 2001 From: Stephen Weeks Date: Sat, 18 Apr 2009 00:27:17 -0600 Subject: [PATCH] [HTTP::Daemon::Clientconn]: method send_headers(*%headers) [kopipasta]: redirect on paste --- bin/kopipasta.pl | 4 ++++ lib/HTTP/Daemon.pm | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/bin/kopipasta.pl b/bin/kopipasta.pl index dfb5d4b..d11b723 100644 --- a/bin/kopipasta.pl +++ b/bin/kopipasta.pl @@ -69,6 +69,10 @@ ($c, $r) sub paste($c, $r) { my $id = save_paste($r.query); + $c.send_status_line(303, 'See Other'); + $c.send_headers(:Location("/$id")); + $c.send_crlf; + $c.close; # TODO Send a redirect instead of 200 OK $c.send_response: show { html { diff --git a/lib/HTTP/Daemon.pm b/lib/HTTP/Daemon.pm index 1bc17b7..9494be8 100644 --- a/lib/HTTP/Daemon.pm +++ b/lib/HTTP/Daemon.pm @@ -184,6 +184,13 @@ class HTTP::Daemon::ClientConn { $.socket.send("

$status $message

"); $.socket.close(); } + + method send_headers(*%headers) { + for %headers.kv -> $k, $v { + $.socket.send("$k: $v"); + self.send_crlf; + } + } } grammar HTTP::headerline {