POST data by HttpWebRequest - very strange sytuation

P

peter

Hi,

I have very strange situation but first description ;)
I have:
1) project in VB.NET, in this f.e. 1 function:

Public Function Login(ByVal UserName As String, ByVal UserPassword As
String, Optional ByVal ConnectionParamList As String = Nothing) As
String

this function use HttpWebRequest to connect to asp site on the server:

httpRequest = HttpWebRequest.Create(url)
httpRequest.Method = "POST"
httpRequest.AllowWriteStreamBuffering = True
httpRequest.Timeout = 6000000
httpRequest.SendChunked = True
httpRequest.ContentLength = Content.Length
httpRequest.Credentials =
System.Net.CredentialCache.DefaultCredentials
....
input = httpRequest.GetRequestStream()

Try
If input.CanWrite Then
If Content.Length > 0 Then
input.Write(Content, 0, Content.Length)
End If
input.Flush()
End If
Finally
input.Close()
End Try

'communication
httpResponse = httpRequest.GetResponse()
... (next StringBuilder and return result)

2) i have project in C#, where i call this Login(...)

result = myObject.Login("loginName", "password",
"some_parameters_as_URL_etc");

3) i have COM+ project in VB6 where i call Login function too (with the
same parameters like in project 2):

rv = myObject.Login(ExternalUserName, ExternalPassword,
ConnectionParams)

And now something strange:

when i call Login from project 2), the communication betwen server with
asp site look like this:

--- START ---

POST /ddd/odbc.asp HTTP/1.1
Content-Length: 133
Expect: 100-continue
Connection: Keep-Alive
Host: 192.168.1.48
HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.1
Date: Sat, 26 Aug 2006 16:00:46 GMT
X-Powered-By: ASP.NET

<TRANSMISION><ACTION>Login</ACTION><PARAMS><LOGIN>John</LOGIN><PASSWORD>Smith</PASSWORD><DBNAME>Northwind</DBNAME></PARAMS></TRANSMISION>HTTP/1.1
200 OK

Server: Microsoft-IIS/5.1
Date: Sat, 26 Aug 2006 16:00:46 GMT
X-Powered-By: ASP.NET
Content-Length: 19
Content-Type: text/xml; Charset=utf-8
Set-Cookie: ASPSESSIONIDCACBDCBR=AABBPADAGMPPMBKBBCFMFOON; path=/
Cache-control: No-cache

<RESULT>OK</RESULT>

--- END ---

<TRANSMISION> and <RESULT> is data whith i sending and receiving and
this is OK

but when i call Login from project described in 3), communication looks
like this:

--- START ---

POST /ddd/odbc.asp HTTP/1.1
Host: 192.168.1.48
Transfer-Encoding: chunked
Expect: 100-continue
HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.1
Date: Sat, 26 Aug 2006 15:15:45 GMT
X-Powered-By: ASP.NET

85
<TRANSMISION><ACTION>Login</ACTION><PARAMS><LOGIN>John</LOGIN><PASSWORD>Smith</PASSWORD><DBNAME>Northwind</DBNAME></PARAMS></TRANSMISION>
0

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Sat, 26 Aug 2006 15:15:45 GMT
X-Powered-By: ASP.NET
Content-Length: 46
Content-Type: text/xml; Charset=utf-8
Set-Cookie: ASPSESSIONIDCACBDCBR=OPABPADAJOABBJAFDLFNJAHE; path=/
Cache-control: No-cache

<RESULT>ERROR: invalid XML in request</RESULT>

--- END ---

Question is:
WHAT IS THIS "85" before sendet XML and "0" after it !?

i search internet and found nothing :/

if someone know something or had similar situation, pleas help me ;)

Best regards,
Peter
 
P

Peter

OK, i resolve this problem.
if i comment line:
httpRequest.SendChunked = True
everything works fine.

Why ? i dont know ;)

Regards,
Peter
 
K

Kevin Jones

Question is:
> WHAT IS THIS "85" before sendet XML and "0" after it !?

You're using chunked-encoding.

Chunked is used when you want to send data between a client and a server
and the receiver wants to start consuming the data before it's all been
sent. Chunked allows the sender to send the data without knowing how
large it is, so the sender doesn't need to calculate the data's size
then set the Content-Length header.

The '85' before the data says: "The size of the next chunk is 85(hex)
bytes. The '0' indicates there is no more data being sent, i.e. this was
the last chunk.

See the HTTP RFC for more details (http://rfc.net/rfc2616.html)

Kevin Jones
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top