Skip to content

Instantly share code, notes, and snippets.

@jhthorsen
Created June 25, 2014 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhthorsen/75e51a92f4e0f589a44f to your computer and use it in GitHub Desktop.
Save jhthorsen/75e51a92f4e0f589a44f to your computer and use it in GitHub Desktop.
How to make a response without headers, http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6
#!/usr/bin/env perl
package No::Headers;
use Mojo::Base "Mojo::Headers";
sub to_string { "" };
package main;
use Mojolicious::Lite;
get "/" => sub {
my $c = shift;
$c->res->content->headers(No::Headers->new) if $c->param('x');
$c->render(text => "test\n");
};
# MOJO_USERAGENT_DEBUG=1 perl without_header.pl get "/?x=1"
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment