EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Http/Https POSTing large amount of data

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#12998
Posted: 04/14/2010 09:06:51
by Ali Sefidpour (Standard support level)
Joined: 04/14/2010
Posts: 9

Hi, I am having a problem currently with POST and large buffers. If I keep the POST data under 8k, no problem, it works fine. As soon as I surpass 8k, I start getting data corruption. What I'll see in the packet outbound is inserted garbage. Here a snippet of a sniffer trace:

Code
00001FF3  74 65 6d 3e 3c 4c 69 6e  65 49 74 65 6d 3e 3c 49 tem><Lin eItem><I
00002003  74 65 6d 43 6f 64 65 3e  30 30 30 35 38 34 39 36 temCode> 00058496
00002013  30 34 33 31 36 3c 2f 49  74 65 6d 43 6f 64 65 3e 04316</I temCode>
00002023  3c 49 74 65 6d 51 75 61  6e 74 69 74 79 3e 31 3c <ItemQua ntity>1<
00002033  2f 49 74 65 6d 51 75 61  6e 74 69 74 79 3e 3c 49 /ItemQua ntity><I
00002043  74 65 6d 54 6f 74 61 6c  43 6f 73 74 3e 31 25 32 temTotal Cost>1%2
00002053  45 35 3c 2f 49 74 65 6d  54 6f 74 61 6c 43 6f 73 E5</Item TotalCos
00002063  74 3e 3c 50 72 6f 64 75  63 74 44 65 73 63 72 69 t><Produ ctDescri
00002073  70 74 69 6f 6e 3e 49 4e  53 54 41 4e 54 2b 52 49 ption>IN STANT+RI
00002083  43 45 2b 31 25 32 45 34  4b 47 3c 2f 50 72 6f 64 CE+1%2E4 KG</Prod
00002093  75 63 74 44 65 73 63 72  69 70 74 69 6f 6e 3e 3c uctDescr iption><
000020A3  53 75 62 44 65 70 61 72  74 6d 65 6e 74 3e 31 3c SubDepar tment>1<
000020B3  2f 53 75 62 44 65 70 61  72 74 6d 65 6e 74 3e 3c /SubDepa rtment><
000020C3  52 65 74 61 69 6c 50 72  69 63 65 3e 31 25 32 45 RetailPr ice>1%2E
000020D3  35 3c 2f 52 65 74 61 69  6c 50 72 69 63 65 3e 3c 5</Retai lPrice><
000020E3  41 63 74 69 76 65 43 6f  73 74 3e 31 25 32 45 30 ActiveCo st>1%2E0
000020F3  38 32 35 3c 2f 41 63 74  69 76 65 43 6f 52 e0 16 825</Act iveCoR..
00002103  00 00 bb 05 00 00 73 74  3e 3c 2f 4c 69 6e 65 49 ......st ></LineI
00002113  74 65 6d 3e 3c 4c 69 6e  65 49 74 65 6d 3e 3c 49 tem><Lin eItem><I


The last ActiveCost end tag has garbage inserted into it. The garbage is random.

The function I wrote to post the data is:

Code
Function THttps.PostData(sUrl,sData:String):Integer;
begin
  Result:=1;
  try
    ReceiveStr:='';
    bResponse:=False;
    ElHttpsCli.SSLEnabled:=UpperCase(copy(sUrl,1,5))<>'HTTP:';
    ElHttpsCli.Url:=sUrl;

    ElHttpsCli.SendStream.Free;
    ElHttpsCli.SendStream:=TMemoryStream.Create;
    ElHttpsCli.SendStream.WriteBuffer(Pointer(sData)^,Length(sData));
    ElHttpsCli.SendStream.Position:=0;
    if ContentType<>'' then
     ElHttpsCli.ContentTypePost:=ContentType;

    ElHttpsCli.PostASync;
[B]    DisplayLog('HTTPS.SendData','data='+sData);[/B]
  except
    On E:Exception do
    begin
      DisplayLog('HTTPS.SendData Error: ',E.Message);
    end;
  end;

The highlighted line shows the complete packet without corruption. The only way to see it is with a sniffer.

It definitely occurs at the 8192 mark of the content data (0x00ff to 0x20ff)

This is reproducable every time.

Thanks!

Don Lafontaine
#12999
Posted: 04/14/2010 09:40:50
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.

What this ElHttpsCli object is? Is it the wrapper class for ICS?

We strongly recommend using our own components such as TElHTTPSClient component. Wrapper classes are provided for easy migration of the code, that already uses Indy or ICS components, but for new code we discourage using that wrapper classes.


Sincerely yours
Eugene Mayevski
#13000
Posted: 04/14/2010 09:49:01
by Ali Sefidpour (Standard support level)
Joined: 04/14/2010
Posts: 9

Quote
What this ElHttpsCli object is? Is it the wrapper class for ICS?


Thanks for the quick reply Eugene. I am using TElHttpsCli. Older version of SBB with Delphi 5. I am also using ICS.

(I checked the newer versions trials, and looked through the change list and I don't see any significant changes that would suggest a bug fix.)
#13001
Posted: 04/14/2010 10:04:37
by Eugene Mayevski (EldoS Corp.)

I am afraid that we won't be able to help you in this case, as, even if the bug is found in ICS or in our wrapper class, it would require an upgrade.


Sincerely yours
Eugene Mayevski
#13013
Posted: 04/15/2010 13:16:30
by Ali Sefidpour (Standard support level)
Joined: 04/14/2010
Posts: 9

Here are two snippets of code that should do exactly the same thing. The ICS version works where the blackbox one fails. Make sure the file is over 9000 bytes to be sure. I tried this with the latest eval 4-7 and it still didn't work.

Code
{BlackBox}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
    ElHttpsCli.SSLEnabled:=False;
    ElHttpsCli.Url:='http://s.wizardsizus.ca/loc_dev/locDevPOS.aspx';

    ElHttpsCli.SendStream.Free;
    ElHttpsCli.SendStream:=TMemoryStream.Create;
    TMemoryStream(ElHttpsCli.SendStream).LoadFromFile('LN9011_ITEM_REQUEST.XML');
    ElHttpsCli.SendStream.Position:=0;

    ElHttpsCli.PostASync;
end;


Code
{FPiette}
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
    HttpCli.Url:='http://s.wizardsizus.ca/loc_dev/locDevPOS.aspx';
    HttpCli.SendStream.Free;
    HttpCli.SendStream:=TMemoryStream.Create;
    TMemoryStream(HttpCli.SendStream).LoadFromFile('LN9011_ITEM_REQUEST.XML');
    HttpCli.SendStream.Position:=0;

    HttpCli.PostASync;
end;


Regards,

Don.
#13014
Posted: 04/15/2010 13:31:56
by Eugene Mayevski (EldoS Corp.)

Moved to helpdesk for checking and fixing.


Sincerely yours
Eugene Mayevski
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 1527 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!