West Wind Internet and Client Tools
POST Raw Data may be altered in httpgetex()
Gravatar is a globally recognized avatar based on your email address. POST Raw Data may be altered in httpgetex()
  Matthias
  All
  Feb 6, 2016 @ 04:26pm
Hi Rick,

I found a bug in your wwipstuff.vcx, when transferring raw data using POST with methode httpgetex().
In this methode you have some code, that removes a "&" when this char is at the end of the post buffer.
That might be okay when used with url encoded form data, but not with any other data!

I am using the http post to transfer raw file contents, e.g. a zip-file, in chunks of 500kb. So I am using several POSTs to transfer a file part by part, chunk by chunk.
And if such a chunk had an "&" as last character, that char had been removed, so the transferred file was garbage, unusable.

It took me several hours to find out, that your library was altering the data ;-)

So, when removing the trailing "&" char, you should only do that when nhttppostmode is set to 1 - Form URLEncoded (default).

IF !EMPTY(THIS.cPostBuffer)
IF This.nhttppostmode == 1 AND RIGHT(THIS.cPostBuffer,1) = "&" THEN
***************************
THIS.cPostbuffer = LEFT(THIS.cPostbuffer,LEN(THIS.cPostBuffer)-1)
ENDIF
tnPostSize=LEN(THIS.cPostBuffer)
lcPostBuffer= IIF(tnPostSize > 0,THIS.cPostBuffer,NULL)
ELSE
tnPostSize=0
lcPostBuffer=NULL
ENDIF

Matthias

Gravatar is a globally recognized avatar based on your email address. Re: POST Raw Data may be altered in httpgetex()
  Rick Strahl
  Matthias
  Feb 7, 2016 @ 06:44pm
Matthias,

if you're still using wwipstuff.vcx you're using code that's been deprecated 15+ years ago. Please check wwhttp.prg and see if the same behavior existst there. Just doing a quick check there, I don't see code that does anything like this any longer.

+++ Rick ---



Hi Rick,

I found a bug in your wwipstuff.vcx, when transferring raw data using POST with methode httpgetex().
In this methode you have some code, that removes a "&" when this char is at the end of the post buffer.
That might be okay when used with url encoded form data, but not with any other data!

I am using the http post to transfer raw file contents, e.g. a zip-file, in chunks of 500kb. So I am using several POSTs to transfer a file part by part, chunk by chunk.
And if such a chunk had an "&" as last character, that char had been removed, so the transferred file was garbage, unusable.

It took me several hours to find out, that your library was altering the data ;-)

So, when removing the trailing "&" char, you should only do that when nhttppostmode is set to 1 - Form URLEncoded (default).

IF !EMPTY(THIS.cPostBuffer)
IF This.nhttppostmode == 1 AND RIGHT(THIS.cPostBuffer,1) = "&" THEN
***************************
THIS.cPostbuffer = LEFT(THIS.cPostbuffer,LEN(THIS.cPostBuffer)-1)
ENDIF
tnPostSize=LEN(THIS.cPostBuffer)
lcPostBuffer= IIF(tnPostSize > 0,THIS.cPostBuffer,NULL)
ELSE
tnPostSize=0
lcPostBuffer=NULL
ENDIF

Matthias




Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

© 1996-2024