EldoS | Feel safer!

Software components for data protection, secure storage and transfer


Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
Posted: 04/14/2009 17:08:33
by Rick  (Basic support level)
Joined: 04/14/2009
Posts: 6

I have a need to see what is being posted when I execute HTTPSClient.Post(edURL.Text, SL, "DocumentBlob", FilePath, stream, "multipart/form-data", true);

I am using the example VS2008 solution to prototype a solution. The SL variable is defined as TElStringList SL = new TElStringList() and I am added 8 name/value pairs, two of which are username and password. After searching for several hours I have not been able to see where the contents of the SL variable are part the stream I am trying to post. Is there anyway to see what the Post method is sending to the server as a request? With a content type of multipart/form-data I would also expect to see the boundary delimiter betwwen each of my fields, is there anything special I need to do to accomplish this? Thanks for assistance.

Posted: 04/14/2009 23:12:48
by Ken Ivanov (EldoS Corp.)

Thank you for contacting us.

Unfortunately, there's no way to intercept data sent to the server at the moment. We will add an event to track this in the upcoming build update.

After searching for several hours I have not been able to see where the contents of the SL variable are part the stream I am trying to post.

How exactly do you add the name/value pairs to the string list? The following code should be used:
SL.Add("name1", "value1");
SL.Add("name2", "value2");
Posted: 04/15/2009 09:10:40
by Rick  (Basic support level)
Joined: 04/14/2009
Posts: 6

Yes, I am using the add method to construct the variables for the web form. I have also modified the HTTPVersion to 1.1.
Posted: 04/15/2009 09:32:45
by Ken Ivanov (EldoS Corp.)

Can you please provide us with a chunk of code you are using?
Posted: 04/15/2009 10:53:41
by Rick  (Basic support level)
Joined: 04/14/2009
Posts: 6

The core of the code came from your sample code for posting HTTP.

Please do not confuse the username and password as sometype of forms authtentication. It is not. They are parameters on the form that need to be passed in. The URL is using https. I have the my commented out code in the example to show different things I have tried. Some of the variable settings where tried to try an mimic what is being sent.

[/code] private void btnPost_Click(object sender, System.EventArgs e)
if (edPath.Text.Length > 0 && edURL.Text.Length > 0)
//HTTPSClient.RequestParameters.ContentType = "multipart/form-data";
mmLog = new StringBuilder();
string FilePath = edPath.Text.Trim();
Stream stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read);
TElStringList SL = new TElStringList();
SL.CaseSensitive = false;
SL.Add("UserName", "aaaaa");
SL.Add("Password", "bbbbbbbb");
SL.Add("User", "ccccccc");
SL.Add("SiteID", "dddddddd");

//HTTPSClient.RequestHeaders.Add("UserName", "aaaaa");
//HTTPSClient.RequestHeaders.Add("Password", "bbbbbbb");
//HTTPSClient.RequestHeaders.Add("User", "cccccc");
//HTTPSClient.RequestHeaders.Add("SiteID", "3333333");
pbUploading.Minimum = 0;
pbUploading.Maximum = (int) (stream.Length / 1024);
pbUploading.Value = 0;
//HTTPSClient.SSLEnabled = true;
HTTPSClient.UseCompression = true;
HTTPSClient.PreferKeepAlive = true;
HTTPSClient.UseCompression = true;
HTTPSClient.RawOutput = new FileStream(@"c:\o.txt", FileMode.Append, FileAccess.Write);
//HTTPSClient.RequestParameters.AcceptCharset = "ISO-8859-1,utf-8;q=0.7,*;q=0.7";
//HTTPSClient.RequestParameters.AcceptLanguage = "en-us,en;q=0.5";
//HTTPSClient.RequestParameters.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
//HTTPSClient.RequestParameters.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/2009032609 Firefox/3.0.8 (.NET CLR 3.5.30729)";
//HTTPSClient.RequestParameters.Host = "localhost:7771";
//HTTPSClient.OutputStream = new FileStream(@"c:\o.txt", FileMode.Append, FileAccess.Write);
HTTPSClient.Post(edURL.Text, SL, "DocumentBlob", FilePath, stream, "multipart/form-data", true);
catch (Exception E)
MessageBox.Show("Exception happened during HTTP post: " + E.Message);

private void HTTPSClient_OnCertificateValidate(object Sender, SBX509.TElX509Certificate X509Certificate, ref bool Validate)
Validate = true;
// NEVER do this in real life since this makes HTTPS security void.
// Instead validate the certificate as described on http://www.eldos.com/sbb/articles/1966.php

private void HTTPSClient_OnData(object Sender, byte[] Buffer)

private void HTTPSClient_OnPreparedHeaders(object Sender, TElStringList Headers)
//this.HTTPSClient.RequestHeaders.Add("UserName", "aaaaaaa");
//this.HTTPSClient.RequestHeaders.Add("UserName", "aaaaaaaa");
//this.HTTPSClient.RequestHeaders.Add("Password", "aaaaaaa");
//this.HTTPSClient.RequestHeaders.Add("User", "aaaaaa");
//this.HTTPSClient.RequestHeaders.Add("SiteID", "aaaaaaaa");
Posted: 04/15/2009 10:59:25
by Rick  (Basic support level)
Joined: 04/14/2009
Posts: 6

Here is a dump of what is being sent to web server:

Host: localhost:7771
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/2009032609 Firefox/3.0.8 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------24464570528145
Content-Length: 1045

Content-Disposition: form-data; name="UserName"

Content-Disposition: form-data; name="Password"

Content-Disposition: form-data; name="User"

Content-Disposition: form-data; name="SiteID"

Content-Disposition: form-data; name="DCount"

Content-Disposition: form-data; name="DAmount"

Content-Disposition: form-data; name="CCount"

Content-Disposition: form-data; name="CAmount"

Content-Disposition: form-data; name="DocumentBlob"; filename="testdata.txt"
Content-Type: text/plain

Posted: 04/15/2009 11:12:00
by Rick  (Basic support level)
Joined: 04/14/2009
Posts: 6

For clarification, the previous post, the dump, is from the vendor's html form post.
Posted: 04/17/2009 00:09:30
by Ken Ivanov (EldoS Corp.)

Thank you for the code. The code itself is correct and should work. Doesn't it for you?
Posted: 04/27/2009 09:04:44
by Rick  (Basic support level)
Joined: 04/14/2009
Posts: 6

No, it does not work for me. My guess is that the format I provided that is necessary with content type of multipart/form-data; is not be reproduced correctly; hence my original question about seeing the output (genereated html) from the various sbb commands.
Posted: 04/27/2009 09:39:10
by Ken Ivanov (EldoS Corp.)

Please install the 7.0.156 build, released a week ago. We extended TElHTTPSClient interface with OnSendData event, which allows to track the request data being sent to server.
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.



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