Roxen.git/
server/
protocols/
http.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2008-02-15
2008-02-15 16:37:47 by Martin Stjernholm <mast@lysator.liu.se>
6110fd30a9b67b4c43236ffe5820e83cd577e946 (
158
lines) (+
78
/-
80
)
[
Show
|
Annotate
]
Branch:
5.2
Some code cleanup (mostly indentation change).
Rev: server/protocols/http.pike:1.543
2:
// Modified by Francesco Chemolli to add throttling capabilities. // Copyright © 1996 - 2004, Roxen IS.
-
constant cvs_version = "$Id: http.pike,v 1.
542
2008/
01
/
16
09
:
32
:
08
grubba
Exp $";
+
constant cvs_version = "$Id: http.pike,v 1.
543
2008/
02
/
15
16:
37
:
47
mast
Exp $";
// #define REQUEST_DEBUG #define MAGIC_ERROR
480:
} #endif
-
private static mixed f, line;
-
private static int hstart;
-
+
#if 0 //! Parse cookie strings. //!
662:
} static Roxen.HeaderParser hp = Roxen.HeaderParser();
-
static function(string:array(string|mapping)) hpf = hp->feed;
-
int last;
+
private int parse_got( string new_data ) {
-
+
string line;
+
TIMER_START(parse_got); if( !method ) { if (!hrtime) hrtime = gethrtime(); array res;
-
if( mixed err = catch( res =
hpf
( new_data ) ) ) {
+
if( mixed err = catch( res =
hp->feed
( new_data ) ) ) {
#ifdef DEBUG report_debug ("Got bad request, HeaderParser error: " + describe_error (err)); #endif
684:
TIMER_END(parse_got); return 0; // Not enough data }
-
data
= res[0];
-
line
= res[1];
-
request_headers = res
[2]
;
+
[
data
,
line
,
request_headers
]
= res;
}
-
+
hp = 0;
TIMER_END(parse_got);
-
return parse_got_2();
-
}
+
-
private
final
int
parse_got_2
( )
-
{
+
//
The following was earlier a separate function
parse_got_2
.
+
TIMER_START(parse_got_2); TIMER_START(parse_got_2_parse_line);
-
string trailer, trailer_trailer;
-
multiset
(string)
sup;
-
string
a, b, s="", linename, contents
;
+
{
+
string
f
;
array(string) sl = line / " "; switch( sizeof( sl ) ) {
749:
TIMER_END(parse_got_2); return 2; }
-
s
=
data = ""; // no headers or extra data...
+
data = ""; // no headers or extra data...
sscanf( f, "%s%*[\r\n]", f ); if (sizeof(sl) == 1) NO_PROTO_CACHE();
767:
time = predef::time(1); // if(!data) data = ""; //REQUEST_WERR(sprintf("HTTP: raw_url %O", raw_url));
+
}
if(!remoteaddr) {
863:
} } TIMER_END(parse_got_2_parse_headers);
+
TIMER_START(parse_got_2_more_data); if(misc->len) {
910:
} foreach(replace(data,"+"," ")/"&", v)
-
if(sscanf(v, "%s=%s", a, b) == 2)
+
if(sscanf(v, "%s=%s",
string
a,
string
b) == 2)
{ a = http_decode_string( a ); b = http_decode_string( b );
953:
leftovers = data; } TIMER_END(parse_got_2_more_data);
+
if (!(< "HTTP/1.0", "HTTP/0.9" >)[prot]) { if (!misc->host) { // RFC 2616 requires this behaviour.
968:
} } TIMER_END(parse_got_2);
+
return 3; // Done. }