1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
commit 331d5c1d1f0e48e6b57ef738c2a8509b1eb53376
Author: Theo van Hoesel <tvanhoesel@perceptyx.com>
Date: Thu Jun 16 08:17:39 2022 +0000
Rename variables
can not remember 2-letter abreviation more than 100 lines below
diff --git a/lib/HTTP/Daemon.pm b/lib/HTTP/Daemon.pm
index a02486c..c0cdf76 100644
--- a/lib/HTTP/Daemon.pm
+++ b/lib/HTTP/Daemon.pm
@@ -192,9 +192,9 @@ READ_HEADER:
}
# Find out how much content to read
- my $te = $r->header('Transfer-Encoding');
- my $ct = $r->header('Content-Type');
- my $len = $r->header('Content-Length');
+ my $tr_enc = $r->header('Transfer-Encoding');
+ my $ct_type = $r->header('Content-Type');
+ my $ct_len = $r->header('Content-Length');
# Act on the Expect header, if it's there
for my $e ($r->header('Expect')) {
@@ -209,7 +209,7 @@ READ_HEADER:
}
}
- if ($te && lc($te) eq 'chunked') {
+ if ($tr_enc && lc($tr_enc) eq 'chunked') {
# Handle chunked transfer encoding
my $body = "";
@@ -280,32 +280,32 @@ READ_HEADER:
$r->push_header($key, $val) if $key;
}
- elsif ($te) {
+ elsif ($tr_enc) {
$self->send_error(501); # Unknown transfer encoding
- $self->reason("Unknown transfer encoding '$te'");
+ $self->reason("Unknown transfer encoding '$tr_enc'");
return;
}
- elsif ($len) {
+ elsif ($ct_len) {
# Plain body specified by "Content-Length"
- my $missing = $len - length($buf);
+ my $missing = $ct_len - length($buf);
while ($missing > 0) {
print "Need $missing more bytes of content\n" if $DEBUG;
my $n = $self->_need_more($buf, $timeout, $fdset);
return unless $n;
$missing -= $n;
}
- if (length($buf) > $len) {
- $r->content(substr($buf, 0, $len));
- substr($buf, 0, $len) = '';
+ if (length($buf) > $ct_len) {
+ $r->content(substr($buf, 0, $ct_len));
+ substr($buf, 0, $ct_len) = '';
}
else {
$r->content($buf);
$buf = '';
}
}
- elsif ($ct && $ct =~ m/^multipart\/\w+\s*;.*boundary\s*=\s*("?)(\w+)\1/i) {
+ elsif ($ct_type && $ct_type =~ m/^multipart\/\w+\s*;.*boundary\s*=\s*("?)(\w+)\1/i) {
# Handle multipart content type
my $boundary = "$CRLF--$2--";
@@ -497,8 +497,8 @@ sub send_redirect {
print $self "Location: $loc$CRLF";
if ($content) {
- my $ct = $content =~ /^\s*</ ? "text/html" : "text/plain";
- print $self "Content-Type: $ct$CRLF";
+ my $ct_type = $content =~ /^\s*</ ? "text/html" : "text/plain";
+ print $self "Content-Type: $ct_type$CRLF";
}
print $self $CRLF;
print $self $content if $content && !$self->head_request;
@@ -537,12 +537,12 @@ sub send_file_response {
local (*F);
sysopen(F, $file, 0) or return $self->send_error(RC_FORBIDDEN);
binmode(F);
- my ($ct, $ce) = guess_media_type($file);
+ my ($mime_type, $file_enc) = guess_media_type($file);
my ($size, $mtime) = (stat _)[7, 9];
unless ($self->antique_client) {
$self->send_basic_header;
- print $self "Content-Type: $ct$CRLF";
- print $self "Content-Encoding: $ce$CRLF" if $ce;
+ print $self "Content-Type: $mime_type$CRLF";
+ print $self "Content-Encoding: $file_enc$CRLF" if $file_enc;
print $self "Content-Length: $size$CRLF" if $size;
print $self "Last-Modified: ", time2str($mtime), "$CRLF" if $mtime;
print $self $CRLF;
|