EldoS | Feel safer!

Software components for data protection, secure storage and transfer

HTTPS Post

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#12306
Posted: 02/04/2010 12:41:58
by Steve E (Basic support level)
Joined: 02/04/2010
Posts: 9

Hi, I am struggling on how to append the content of a file to one of my request parameters. I have created a stringlist with the following:

Data=testData
Format=testFormat
Data=

I want to append the content of a file to the Data=, so that the request looks like &Data=testData&Format=testFormat&Data=<content of my data file>

I have tried
Client.Post(URL,sl,'Data','c:\data\datafile.txt')
also trying to a Stream of data
Client.Post(URL,sl,'Data','c:\data\datafile.txt',Stream,'',true)

But neither seem to give me the result I want. Any advise is welcome.

Thanks
Steve
#12307
Posted: 02/04/2010 12:50:54
by Eugene Mayevski (EldoS Corp.)

Do you know what result you must obtain? What you specified doesn't make much sense because this is notation of GET request, where parameters are passed after the question sign of the URL.

If you need to post the form data and a file, you can use the longest form of POST method which lets you post both text data and the stream as a file.


Sincerely yours
Eugene Mayevski
#12309
Posted: 02/04/2010 12:55:51
by Steve E (Basic support level)
Joined: 02/04/2010
Posts: 9

Eugene, thanks for the quick reply. Below is part of the log

User-Agent: SecureBlackbox
Accept-Encoding: gzip, deflate
Content-Length: 64

DataType=TEST&DataFormat=IN&Security=Bypass&Protocol=HTTPS&Data=
6:55:19 PM - sendData Failed - Input Parameters validation error
6:55:19 PM - Post result - code = 200

I would like my file content appended to the &Data=

Steve
#12310
Posted: 02/04/2010 13:05:39
by Eugene Mayevski (EldoS Corp.)

It can be *anything*. If you have a web page, whose behavior you need to duplicate, please copy it's source code from |form| to |/form| tag and past it here for checking. If you have a document or instructions that specify that the data need to be posted, please check these instructions for information about how exactly the data needs to be formatted. The log doesn't explain anything unfortunately.


Sincerely yours
Eugene Mayevski
#12311
Posted: 02/04/2010 13:24:08
by Steve E (Basic support level)
Joined: 02/04/2010
Posts: 9

I am posting the data to WebMethods server, I believe the service wants to see

DataType=TEST&DataFormat=IN&Security=Bypass&Protocol=HTTPS&Data=FILECONTENT

I can get the parameters sent to the receiving server ok, but I cannot seem to get the data appended to the datastream.

If i use a filestream, then I want to append the content to the HTTP request after the Request params
#12312
Posted: 02/04/2010 13:55:36
by Eugene Mayevski (EldoS Corp.)

One option is to put everything you want to post to the byte array or to a stream, and use the method

function TElHTTPSClient.Post(const URL: string; const Content: ByteArray): integer;

This way the data of Content will be transferred as is, as you believe they need to be sent.

Still I suggest that you find the requirements.


Sincerely yours
Eugene Mayevski
#12314
Posted: 02/04/2010 16:02:26
by Steve E (Basic support level)
Joined: 02/04/2010
Posts: 9

The URL expects the parameters as URL Encoded compliant HTTPS form POST
parameters specified within the body of the HTTPS request. The default HTTPS form POST content type should be as : Content:type: application/x-www-form-urlencloded

not sure if this is sufficient information for you. Thanks again for your time.
#12318
Posted: 02/04/2010 23:29:14
by Eugene Mayevski (EldoS Corp.)

Yes, that is fine. In this case the long form of Post method should work.

You call it in the following way:

Code
var
SL : TStringList;
...
SL.Add('DataType=TEST');
SL.Add('DataFormat=IN');
SL.Add('Security=Bypass');
SL.Add('Protocol=HTTPS');

Client.Post(URL, SL, 'Data', 'filename.txt', Stream, '', true);

This will store the data in a standard form post data format.

As you can see from the POST sample and the corresponding PHP code, they work in the described way.


Sincerely yours
Eugene Mayevski
#12319
Posted: 02/05/2010 09:14:29
by Steve E (Basic support level)
Joined: 02/04/2010
Posts: 9

Hi Eugene,

So does this imply that the 5th parameter would "Data=filename.txt", and the file would be uploaded to some location on the server. If that is the case, then it is not what I want to achieve. Lets assume my file content is "abc123xyzzy", then I want the 5th parameter to be "Data=abc123xyzzy" not the file name. I just tried this with ipworks and the file attachment function and it works as I expect. I don't want to manipulate the file in memory as some of them can be very large.

Steve
#12320
Posted: 02/05/2010 09:42:53
by Eugene Mayevski (EldoS Corp.)

No, it doesn't imply any of the above. The requirements you've specified work differently from "Data=abc123xyzzy" as you think them to be. What you want is to pass the contents of the file as if they were put to some web form field.

If you can dump me the contents of what IPWorks sends (and it works for you), I would be able to say how this can be done with SecureBlackbox.Please post some smaller XML file so that we could see if any transformations are performed to the data.

You can capture the data being sent using free packet analyzer (eg. Ethereal, www.ethereal.com).


Sincerely yours
Eugene Mayevski
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

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