EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Using the Post command on HTTPS client

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#37637
Posted: 09/05/2016 16:35:38
by Jeff Newlin (Standard support level)
Joined: 12/26/2010
Posts: 19

Hello again

I am trying to send a message that contains the word "POST" on the first line of the message - it looks like this :

POST /core/eligibility HTTP/1.1
Content-Type: multipart/form-data; boundary=XbCY
Host: wsd.officeally.com
Content-Length: 1212

--XbCY
Content-Disposition: form-data; name=“PayloadType“

X12_270_Request_005010X279A1
--XbCY
Content-Disposition: form-data; name=“ProcessingMode"

RealTime
--XbCY
Content-Disposition: form-data; name=“PayloadID"

e51d4fae-7dec-11d0-a765-00a0c91e6da6
--XbCY

etc.....

I have the entire message loaded up into a string called FString. I use the following command to send the message :

Code
Try
R := HTTPSClient.Post(fURL.Text, FString) ;
Except
on E : Exception do
begin
ShowMessage(E.ClassName + ' error raised, message :' +
'+E.Message);
end;
End;
Code

I checked the value of R and it is 200 (I think that means it was sent ok)


I was wondering if there is a problem with including the word "POST" as the first line of the message that is called using a HTTPSClient.Post command ?

The "OnDocumentBegin" event is triggered as well as the "OnDocumentEnd" event. But the "OnData" does not trigger so I know I have something wrong somewhere!

Thanks for your help!
#37638
Posted: 09/06/2016 02:48:27
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

TElHTTPSClient.Post method generated POST line and headers of the request internaly. You should pass only data part as its parameter. In your case POST and headers are duplicated and most likely this is the reason of the problem.

If you want to post data with headers please consider using TElSimpleSSLClient instead of TElHTTPSClient.
#37702
Posted: 09/13/2016 01:28:55
by Jeff Newlin (Standard support level)
Joined: 12/26/2010
Posts: 19

Thank you for your help.

This is the URL that I am passing to the POST command :

https://wsd.officeally.com/TransactionSite/rtx.aspx


I am checking the headers on the OnPreparedHeaders event and displaying them in a memo component called OutMemo. Below is the code - the support team on the server's end told me I would probably have to add the "Content-Type" header.


Code
     Headers.Add('Content-Type: multipart/form-data; boundary=XbCY');

     for i := 0 to Headers.Count - 1 do
     begin
          OutMemo.Lines.Add(Headers[i] ) ;
     end;


This is what headers I see as the output of the above :

POST /TransactionSite/rtx.aspx HTTP/1.0
Host: wsd.officeally.com:443
User-Agent: SecureBlackbox
Accept-Encoding: gzip, deflate
Content-Length: 1212
Content-Type: multipart/form-data; boundary=XbCY

Is the event OnPreparedHeaders the proper place to alter the headers?

The support people tell me I should expect to "POST" header to look like this :

POST https://wsd.officeally.com/TransactionSite/rtx.aspx HTTP/1.1

The HTTPSClient seems to break this into two lines :

POST /TransactionSite/rtx.aspx HTTP/1.0
Host: wsd.officeally.com:443

I do get data back on this at least - I attached a screen shot of it in a browser.

What do you think?

Thanks!
Jeff
#37703
Posted: 09/13/2016 01:42:29
by Jeff Newlin (Standard support level)
Joined: 12/26/2010
Posts: 19

I'm sorry I can't seem to post the image of the response I am getting (as an attachment)

here is what I get


Jeff
#37704
Posted: 09/13/2016 03:27:33
by Jeff Newlin (Standard support level)
Joined: 12/26/2010
Posts: 19

Here it is
#37705
Posted: 09/13/2016 04:13:59
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
Is the event OnPreparedHeaders the proper place to alter the headers?

Yes it is.

Quote
The support people tell me I should expect to "POST" header to look like this :
POST https://wsd.officeally.com/TransactionSite/rtx.aspx HTTP/1.1

This is not correct. It should look like our client sends it.

Quote
What do you think?

I think you should dump both headers and request body and check if headers are not duplicated as it was according to the code in your initial message. If everything is fine, then most likely some headers expected by the server are missing. Also result code of TElHTTPSClient.Post method may give us more information about the reason of the problem.
#37710
Posted: 09/13/2016 06:56:11
by Eugene Mayevski (EldoS Corp.)

Quote
Jeff Newlin wrote:
Is the event OnPreparedHeaders the proper place to alter the headers?


Yes, and you seem to have got the right result.

Quote
Jeff Newlin wrote:
The support people tell me I should expect to "POST" header to look like this :

POST https://wsd.officeally.com/TransactionSite/rtx.aspx HTTP/1.1


Their suggestion is wrong unless they've given you the address of the proxy instead of the server.


Sincerely yours
Eugene Mayevski
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 726 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!