cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[curl:bugs] #758 VMS-Alpha, http-upload not working

From: John Malmberg <wb8tyw_at_users.sf.net>
Date: Tue, 16 Jul 2013 04:49:15 +0000

I am looking through the source to see the impact of working around this and if there are related bugs.

Generically wrapping stat() is not good because there are several places that stat() is called where the exact file size is not needed, and the workaround has performance impact.

In file.c the call to fstat(fd, ...) is affected by this bug. Because on VMS, the open() done before the call to fstat() locks the file, doing a second open() to read the actual size of the file will fail.

On VMS, we would have to test state.resume_from before the fd = open(file->...) and then calculate the true path and then use that value instead of the fstat() call later.

I do not have a reproducer for this behavior.

In tool_operate.c, for the stat(outfile, ...) section on VMS, additional arguments can be passed to fopen() to force the file format to be the needed STREAM_LF format.

By default if the output file does not exist, it will be created in STREAM_LF format and all will be well.

If the file exists already a new file with the same name will be in the same format as the original, and there is only a problem if that file is not in a STREAM_LF or STREAM_CR format.

For this a reference in the VMS readme file about what the behavior should be the only thing needed as how many times will someone be using curl to replace a VMS format file in a download? I do not have a reproducer for this issue.

Later in tool_operate.c the O_BINARY is a noop on VMS, so the file is opened in "cooked" mode with the record formats translated for text files. The size from fstat() will have the same issue as in this bug. I do not have a reproducer to verify a fix for this issue.

In tool_getparam.c, the st_size member is not referenced, so no VMS specific issues are present.

So it looks like somewhere in lib we need a:

curl_off_t get_vms_file_size(const char *, struct stat *) that can return both the true file size and optionally a stat structure that can be called as needed instead of stat(), or before the open() as above.

So the questions are what name for the function, what module to put it in, and how to patch in the calls to it.

---
** [bugs:#758] VMS-Alpha, http-upload not working**
**Status:** open-confirmed
**Labels:** http VMS 
**Created:** Mon Aug 18, 2008 04:09 PM UTC by Harald Schwarz
**Last Updated:** Tue Jul 16, 2013 01:15 AM UTC
**Owner:** Daniel Stenberg
On VMS-Alpha: 
When using an http-file-upload the file is not sent to the Server with the correct content-length. 
Sending a file with 511 or less bytes, content-length 512 is used. 
Sending a file with 513 - 1023 bytes, content-length 1024 is used. 
Files with a length of a multiple of 512 Bytes show the correct content-length. Only these files work for upload.
Test-Commands on VMS-Alpha, Linux \(Suse\) and Windows: 
curl --form myfile=@test.ras --trace-ascii testras.log http://my\_web\_test\_server/cgi-bin/upload.pl 
curl --form myfile=@test.doc --trace-ascii testdoc.log http://my\_web\_test\_server/cgi-bin/upload.pl
File test.doc has the size 21.504 \(multiple of 512\) 
File test.ras has the size  5.686 \(not a multiple of 512\).
Using test.doc everything works. 
Using test.ras the Content-Length in the LOG-File differs from the content length on Linux/Windows. 
The receiving program \(in my testcase "upload.pl"\) says that I have a post-data mismatch.
VMS shows: 
002c: Content-Disposition: form-data; name="myfile"; filename="test.ra 
006c: s" 
0070: Content-Type: application/octet-stream 
0098: 
=&gt; Send data, 6144 bytes \(0x1800\)
Linux + Windows show: 
002c: Content-Disposition: form-data; name="myfile"; filename="test.ra 
006c: s" 
0070: Content-Type: application/octet-stream 
0098: 
=&gt; Send data, 5686 bytes \(0x1636\)
My workaround: I wrote a perl-program to add some bytes to the file to have a multiple of 512 Bytes. The CGI-Program \(upload.pl\) then reduces the filesize back to the origin.
This workaround works for all files with all sizes - but the error in curl still remains. 
Now I have to say, that I'm not a C-Programmer, so I kindly ask for help.
If you need a VMS-Alpha for testing \(incl. Compiler, ...\), please have a look at www.polarhome.com. 
On VMS-Alpha: before you can use "curl" as a program you have to define a symbol that points to CURL.EXE. 
curl = "$...\[...\]CURL.EXE" 
Then "curl" can be startet as described above.
Used CURL-Version on all systems: 7.18.2.
---
Sent from sourceforge.net because curl-tracker@cool.haxx.se is subscribed to https://sourceforge.net/p/curl/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/curl/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
Received on 2013-07-16

These mail archives are generated by hypermail.

donate! Page updated May 06, 2013.
web site info

File upload with ASP.NET