Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Maximum size of HTTP Post - AddPostKey

$
0
0
Re: Maximum size of HTTP Post - AddPostKey
West Wind Internet Protocols
Re: Maximum size of HTTP Post - AddPostKey
08/06/2012
03:43:48 PM
3KF0XPV1G Show this entire thread in new window
Gratar Image based on email address
From:
Rick Strahl
To:
Attachments:
None
Hi Bill,

Updating to wwFileStream() is a bit of work - I actually did this, then ripped out the code because I managed to get this stuff to work another way, but apparently that's actually not quite working.

When I did the work to add wwFileStream()/wwMemoryStream() there were a lot of places where this needed to be plugged in and it was quite tedious.

My original idea was to just add Assign/Access methods to handle this but for reasons I can't remember now that didn't quite work...

I'll take a look at this at some point again hopefully before the next update if I can find some time between paid work :-)

+++ Rick ---



UPDATE - I modified AddPostKey (see below) to use wwFileStream and it's no longer throwing "String too long", but the web server is now sending back an error "unexpected end of part".

Do I have the right idea as far as modifying to use wwFileStream?

Any idea what the web server is having a problem with?

Thanks.
Bill

*** Check for File Flag - HTTP File Upload - Second parm is filename IF llFileName DO wwapi *** Create a stream l_oStream = CREATEOBJECT("wwFileStream") l_oStream.Write(THIS.cPostBuffer) l_cStr = "--" + MULTIPART_BOUNDARY + CRLF + ; [Content-Disposition: form-data; name="]+tcKey+["; filename="] + JUSTFNAME(tcValue) + ["]+CRLF+CRLF l_oStream.Write(l_cStr) l_oStream.WriteFile(FULLPATH(tcValue)) l_oStream.WriteLine("") THIS.cPostBuffer = l_oStream.ToString() l_oStream.Dispose() l_oStream = .F. *!* Original code - testing modifications for large file uploads. *!* THIS.cPostBuffer = THIS.cPostBuffer + "--" + MULTIPART_BOUNDARY + CRLF + ; *!* [Content-Disposition: form-data; name="]+tcKey+["; filename="] + JUSTFNAME(tcValue) + ["]+CRLF+CRLF *!* this.cPostBuffer = this.cPostBuffer + FILETOSTR(FULLPATH(tcValue)) *!* this.cPostBuffer = this.cPostBuffer + CRLF ELSE this.cPostBuffer = this.cPostBuffer +"--" + MULTIPART_BOUNDARY + CRLF + ; [Content-Disposition: form-data; name="]+tcKey+["]+CRLF+CRLF this.cPostBuffer = this.cPostBuffer + tcValue ENDIF ENDCASE

Rick and LLS, thanks for the clarifications and suggestions.

I'll see about customizing the AddPostKey method, and will look forward to a more "official" Client Tools update that supports > 16MB files. All in all, this was a good excersize, because every time I review the docs for the WW Client Tools, I find some cool tool or other functionality I hadn't noticed before (or most likely, had forgotten).

Bill


> In my memory, the FILETOSTR() is limited to16Mb.

It's not. You can always assign a huge string to a variable. I've been able to read 800 meg file into a string. It works. Doing something with that string is problematic though unfortunately.

One workaround is to use a file stream as described here:

http://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=882

However, I've found that as Bill points out - wwHttp still doesn't work properly as the file concatenation of a 16 meg+ string to another string fails. You can make an initial assigment but you can't assign a 16meg plus string to another string.

Confusing - but the approach with a file dump and then reading the entire large file content into a string var when done manipulating works.

+++ Rick ---


Hi

In my memory, the FILETOSTR() is limited to16Mb.

You must proceed by concatenation of reading the file contents, after it opened by FOPEN (), by reading in a variable with FREAD () blocks of 65535 bytes and after FCLOSE()

In that case, the memory limit of the variable, is define by your hardware memory.

Regards


UPDATE - scratch that about the REPLICATE example, I had accidentally added another zero, which is what was causing it to fail. In actuality, I can run the concatentation command repeatedly to get a multi-hundred-million character long string, as long as each string being concatenated is not > 16MB.

It looks like no matter what, I get an error whenever what is being concatenated is > 16MB.

Another example, I rebooted my workstation, ran only the VFP IDE and issued this from the command line:

_screen.Tag = _screen.Tag + FILETOSTR("PathAndFilename")

Anything greater than 16MB fails.

Does that help? Are you sure you're able to concatenate strings > 16MB?

Thanks.

------------------


VFP9 SP2. Help|About says Version 09.00.0000.6303

It's hard to believe I'm running out of memory, my workstation has 4GB and the task manager says I have 1GB free.

Although, I tried one of your examples (see below) and was able to get it to run once, but not a second time, even after launching a fresh IDE. On other workstations, it hasn't worked even once.

This is a real show stopper for me... Do you happen to have a .NET version of the West Wind Client Tools (assuming .NET would not have the same memory limitation)?


lcString = REPLICATE("1234567890",1500000) lcString = lcString + REPLICATE("1234567890",10000000) ? LEN(lcString)


Bill,

That works for me. I can get 50 meg files to upload...

The huge file I can sort of see (as you really may be running VFP out of memory), but files in smaller ranges should work. You are running VFP 9 right? I think this is something that was introduced in 9 and didn't work in 8 and before.

+++ Rick ---


UPDATE - I did the same test on a straight MP3 file 16,714KB in size and got the same error, other files < 16MB are not having a problem.

Am I running the test scenario properly?

Bill


--------------------

The file in question is a 186MB PDF document (it has a 186MB MP3 Audio file attached/embedded).

From the VFP IDE, I created a simple form with a command button. In the click I added this:

THIS.TAG = THIS.TAG + FILETOSTR(FULLPATH("PathAndFilename"))

Ran the form, clicked the button, and "String too long" error.

I'll try with smaller files to see if I can find a limit > 16MB.


What is the code that's calling this? Can you post repro scenario?
This should work, unless you are running out of memory...

+++ Rick ---



Hello Rick,

We have a new requirement to post large multimedia files via HTTPS and we're running into the "String too long" error. I've downloaded the latest West Wind Client Tools and am still getting the error even though I'm passing a filename to AddPostKey.

Here's what our ErrorHandler is throwing, any ideas?

Thanks.
Bill

---------------------------
Error
---------------------------
Error #: 1903

Message: String is too long to fit.

Line #: 217

Code: this.cPostBuffer = this.cPostBuffer + FILETOSTR(FULLPATH(tcValue))

Method: addpostkey

Choose Yes to display the debugger, No to continue without the debugger, or Cancel to exit the application.
---------------------------
Yes No Cancel
---------------------------



Sean,

You might find this interesting:
http://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=882

+++ Rick ---

Rick,

Can you help me understand your "(files uploaded can be larger)" below? In our desktop software I've got some code to send a file through http, but if it's over a certain size it bombs. It's not an IIS thing in this case, it happens during the 'addpostkey' method when it's doing the:

THIS.cPostBuffer = THIS.cPostBuffer + ;
"--" + MULTIPART_BOUNDARY + CR + ;
[Content-Disposition: form-data; name="]+tcKey+["; filename="] + tcValue + ["]+CR+CR+;
FILETOSTR(tcValue) + CR

Obviously, filetostr has a limit of 16mb and strangely it does convert to a string, but when it's added to another, a 'string too long' error comes up.

Maybe I'm missing something here. What are my options for sending a file > 16mb?

Sample code of mind:
...
.ohttp.nHTTPPostMode = 2
.ohttp.addpostkey("lmscode",GenerateLMSWebSecurityString())
.oHttp.AddPostKey("File",m.cPathFile,.T.)
IF ! .HTTPGet("FileUpload.acs","",.t.)
...

Thanks,
Sean


Javier,

It sounds like this is a SERVER error not a client error, and you really have no control over this from client code. I suspect the server has a limit on the size of POST data allowed to be posted to the server. Most servers have this configurable. You might also be bumping up against a server request timeout if the upload takes too long and goes beyond the server's request timeout. ALl of these are server configuration issues though, and you can't control these from the client. wwHttp just sends the data, the server has to receive it and process it.

There's no reason that this should not work from the wwHttp end of things. You should be able to send strings and files up to the size of VFP's string limit at 15 megabytes (files uploaded can be larger)

Hope this helps,

+++ RIck ---


Hi, I'm using wwIPSTuff to post data to a Web Server using the AddPostKey() method. All works fine, but, right now I have a problem when the data is too big.

The method works fine with small data, but when I try to send like 3-5 MB I get error 500 - Server Error.

How can I indicate the maximum size of the Post??

Best Regards.
Javier Leal.



















Rick Strahl
West Wind Technologies

Making waves on the Web

from Maui, Hawaii

Viewing all articles
Browse latest Browse all 10393

Trending Articles