From: b Date: Fri, 13 Nov 2015 18:13:10 +0000 (+0000) Subject: Fixed header processing. X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=05b50805e43d62e288cacacdc459a9f48fd749a2;p=yplom%2Fproxy Fixed header processing. git-svn-id: svn://botcastle1b/yplom/proxy@7 05ce6ebb-7522-4a6e-a768-0026ae12be9f --- diff --git a/proxy.1.pl b/proxy.1.pl index ad41fa3..e86d433 100755 --- a/proxy.1.pl +++ b/proxy.1.pl @@ -85,7 +85,6 @@ sub proxy { $uppath=$temppath.'u'; } while (( -e $headpath) or ( -e $downpath) or ( -e $uppath)); - # @curl_arg=(CURL_PATH,'-o',$downpath,'-D',$headpath); #-s @curl_arg=(CURL_PATH,'-i','-#'); #-s if ($ENV{'REQUEST_METHOD'} eq 'HEAD'){ @@ -104,32 +103,44 @@ sub proxy { } } close ($upfile); + $craetedup=1; push @curl_arg, '--data-binary'; push @curl_arg, '@'.$uppath; } + foreach $envk (keys %ENV) { - if ($envk =~ /^(HTTP_[A-Z_]+)$/) { + if ($envk =~ /^(HTTP_[A-Z0-9_]+)$/) { $headname=formatheader($1); - if ($ENV{$envk} =~ /^([\x20-\x7e]*)$/) { - $headval=$1; - } - if(lc($headname) =~ REQUEST_HEADER_BLOCK) { - next; - } - unless (exists $ENV{'HTTP_USER_AGENT'}) { - push @curl_arg, '-H'; - push @curl_arg, 'User-Agent:'; - } - unless (exists $ENV{'HTTP_ACCEPT'}) { - push @curl_arg, '-H'; - push @curl_arg, 'ACCEPT:'; - } - $headval=~ s/[\r\n]//g; - $headarg=$headname.(($headval eq '')?';':': '.$headval); - push @curl_arg, '-H'; - push @curl_arg, $headarg; } + elsif ($envk =~ /^(CONTENT_[A-Z0-9_]+)$/) { + $headname=formatheader($1); + } + else { + next; + } + if ($ENV{$envk} =~ /^([\x20-\x7e]*)$/) { + $headval=$1; + } + else { + next; + } + if(lc($headname) =~ REQUEST_HEADER_BLOCK) { + next; + } + + $headarg=$headname.(($headval eq '')?';':': '.$headval); + + push @curl_arg, '-H'; + push @curl_arg, $headarg; + } + unless (exists $ENV{'HTTP_USER_AGENT'}) { + push @curl_arg, '-H'; + push @curl_arg, 'User-Agent:'; + } + unless (exists $ENV{'HTTP_ACCEPT'}) { + push @curl_arg, '-H'; + push @curl_arg, 'ACCEPT:'; } push @curl_arg, $URL; @@ -274,6 +285,10 @@ sub proxy { close(STDREAD); close(ERRREAD); + if ($createdup) { + unlink $uppath; + } + if($safeerror){ return fail("Status: 500 Internal Server Error\n","500 Internal Server Error",$errormsg); }