Based on looking at Apache access log files for several years, I believe that we can rely on the following to be true (assuming we are using the default log format):
1. The method is always present.
2. The request URI is always present, and may or may not contain query params, but will never contain spaces
3. The version may not be present.
So, I propose that you split off the method+uri, treat the remainder as version and use the URI::Split module to break apart the URI:
use URI::Split;
sub split_request
{
my @parts=split(/ /,$_[0]);
scalar(@parts)>=2 or die "Bad request '$_[0]'";
my $method=shift @parts;
my $uri=shift @parts;
my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
my $protover=join(' ',@parts);
return ($method,$scheme,$auth,$path,$query,$frag,$protover);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.