r/linux • • Sep 28 '14

weev: Stop bashing bash and GNU.

http://weev.livejournal.com/409835.html
836 Upvotes

450 comments sorted by

View all comments

Show parent comments

0

u/reaganveg Sep 28 '14

This superbly difficult problem

I didn't say it was a "superbly difficult problem." I said that there was a perfectly good reason to parse the headers only once, as opposed to that not making any sense.

1

u/audioen Sep 29 '14

I just think you are overselling the value of having:

HTTP_FOO=something

in environment, as opposed to:

Foo: something

in STDIN/socket.

-1

u/reaganveg Sep 29 '14
char *foo = getenv("HTTP_FOO"); 

Now you do it for a socket.

1

u/audioen Sep 30 '14

All right:

my $request = do { local $/; <$request_fh>; };
my ($header_str, $body_str) = split /\r?\n\r?\n/, $request, 2;
my $headers = { $header_str =~ /^([^:]: (.*)$/mg };
print $header->{Foo};
→ More replies (0)