You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/AnyEvent/HTTP/Server.pm
+79-18Lines changed: 79 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,9 @@ AnyEvent::HTTP::Server - AnyEvent HTTP/1.1 Server
6
6
7
7
=cut
8
8
9
+
our$VERSION;
9
10
BEGIN{
10
-
our$VERSION = '1.99992';
11
+
$VERSION = '1.99993';
11
12
}
12
13
13
14
#use common::sense;
@@ -30,6 +31,7 @@ use Errno qw(EAGAIN EINTR);
30
31
use AnyEvent::Util qw(WSAEWOULDBLOCK guard AF_INET6 fh_nonblocking);
31
32
use Socket qw(AF_INET AF_UNIX SOCK_STREAM SOCK_DGRAM SOL_SOCKET SO_REUSEADDR IPPROTO_TCP TCP_NODELAY);
32
33
34
+
use Carp ();
33
35
use Encode ();
34
36
use Compress::Zlib ();
35
37
use MIME::Base64 ();
@@ -54,21 +56,35 @@ my $ico_pk = pack "H*",
54
56
"1d8c7e040000";
55
57
our$ico = Compress::Zlib::memGunzip $ico_pk;
56
58
59
+
our$ERROR_TEMPLATE = <<"EOD";
60
+
<html>
61
+
<head><title>%1\$s %2\$s</title></head>
62
+
<body bgcolor="white">
63
+
<center><h1>%1\$s %2\$s</h1></center>
64
+
<hr><center>${\__PACKAGE__}/$VERSION</center>
65
+
</body>
66
+
</html>
67
+
EOD
68
+
57
69
substart { croak "It's a new version of ".__PACKAGE__.". For old version use `legacy' branch, or better make some minor patches to support new version" };
58
70
substop { croak "It's a new version of ".__PACKAGE__.". For old version use `legacy' branch, or better make some minor patches to support new version" };
59
71
60
72
subnew {
61
73
my$pkg = shift;
62
74
my$self = bless {
63
75
backlog=> 1024,
64
-
read_size=>4096,
65
-
max_header_size=> MAX_READ_SIZE,#4096*8,
76
+
read_size=>MAX_READ_SIZE,
77
+
max_header_size=> MAX_READ_SIZE,
66
78
request=>'AnyEvent::HTTP::Server::Req',
67
79
sockets=> {},
68
80
@_,
69
81
active_requests=> 0,
70
82
active_connections=> 0,
71
83
}, $pkg;
84
+
85
+
if ($self->{max_header_size} > $self->{read_size}) {
86
+
Carp::croak "max_header_size can't be greater than read_size";
87
+
}
72
88
73
89
evalqq{ use $self->{request}; 1}
74
90
ordie"Request $self->{request} not loaded: $@";
@@ -224,7 +240,7 @@ sub noaccept {
224
240
subdrop {
225
241
my ($self,$id,$err) = @_;
226
242
$err =~ s/\015//sg;
227
-
#warn "Dropping connection $id: $err (by request from @{[ (caller)[1,2] ]})";# if DEBUG or $self->{debug};
243
+
warn"Dropping connection $id: $err (by request from @{[ (caller)[1,2] ]})"if DEBUG; # or $self->{debug};
0 commit comments