I’m working on a windows 10/Apache/dHTML (Perl) platform trying to upload an .HTML file. I have a form that allows me to browse to select the file I want to upload. The form line follows.
<FORM encTYPE='multipart/FORM-data' ACTION='uploadx.cgi' NAME='ManMe' METHOD='POST' ONSUBMIT='return reqchk()'>n";
I’m getting the correct path and file to upload and destination path and file in uploadx.cgi as shown next as comments. The actual upload code follows.
# comment - $upload_filehandle is C:usrwwwkyhealth.html - correct input location
$upload_filehandle = $page->upload("filex"); # File handle to uploaded file.
# comment - $thefn C:/Steep/USAData/State/KY/Ideals/Health/kyhealth.html - correct output location
open(my $UF_fh,'>',$thefn) || croak "Couldn't open file $filex, $!";
if (index(lc($thefn),'.gif') > -1) {
binmode($UF_fh); # Set file output to binary mode if image.
}
while ( <$upload_filehandle> ) {
print $UF_fh; # Write it out.
}
close $UF_fh;
The errors in the Apache log file from the execution of uploaddx.cgi follow.
[Wed Jun 23 15:16:44.349636 2021] [core:error] [pid 9772:tid 1056] [client 192.253.246.153:62520] malformed header from script ‘uploadx.cgi’: Bad header: , referer: http://steepusa.no-ip.info/scx/cmf2mme.cgi?strmme=SKY_458~422~438~428~430~382_326~366~438~458~450~392_U_level3_326~366~438~458~450~392[Wed Jun 23 15:16:44.349636 2021] [perl:warn] [pid 9772:tid 1056] /scx/uploadx.cgi did not send an HTTP header
The output file is created with the right name in the right place. But the file has zero bytes.
there is no ‘Content-type: text/html’ header in the uploadx.cgi file. It just tries to upload
the file and put it in new file in a particular directory as shown above. And the ‘Bad Header:’ is not telling me much.
I have looked at quite a few posts here and elsewhere about similar problems with no luck. Any help would be appreciated. I’m not sure how to move the ball on this one. Thanks.
ct
3
Answers
It turns out that I'm experiencing significant degradation of ping, download and upload speeds. My upload speed was actually zero when I just did a speedtest with my provider. My telecommunications provider has opened a ticket. This is the first time I've encountered this situation. Thanks ikegami.
The first message follows from the first. The header emitted by the script is malformed in the sense that not emitting any header at all is a malformed header/response.
HTTP requests must result in a response. You seem to be claiming that you do not send a response, which would result in exactly this kind of error. When you use a CGI script, the onus falls on the script to produce this response. If you don’t, the server will typically send a 500 error response and log a message such as the one you asked about.
Keep in mind that a common reason for a script not sending a header is because it died (from a compile-time or run-time error) before it got a chance to do so. A situation such as this one should have left an earlier message in the log file.
I changed from a hotspot internet connection to a router and that solved the malformed header problem. All upload tests were successful with the router connection.