Skip to content

Commit

Permalink
[HTTP::Daemon::Clientconn]: method send_headers(*%headers)
Browse files Browse the repository at this point in the history
[kopipasta]: redirect on paste
  • Loading branch information
tene committed Apr 18, 2009
1 parent 3f520b3 commit a9b7dce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/kopipasta.pl
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions lib/HTTP/Daemon.pm
Expand Up @@ -184,6 +184,13 @@ class HTTP::Daemon::ClientConn {
$.socket.send("<h1>$status $message</h1>");
$.socket.close();
}

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

grammar HTTP::headerline {
Expand Down

0 comments on commit a9b7dce

Please sign in to comment.