0

Hi everyone!
First, sorry for my bad English!

I have a problem with httplib...
I must send XML contain throu HTTP protocol, and here is my code

import sys
import httplib

xml = """ 
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE Doc SYSTEM "TenorOAM.dtd">
<Doc date="1196693972484" from="10.1.1.180" nid="CMS000001" sid="94" to="85.90.74.15">
<ReqMsg><MsgHead mid="1"/><Cmd><New><ObjPath><Instance otype="Null" oid="Null"/>
<Child otype="Endpoint" id="test"/></ObjPath></New></Cmd></ReqMsg></Doc>"""


webservice = httplib.HTTP("85.90.74.15:8080")
webservice.putrequest("POST", "/CallRouter/oam")
webservice.putheader("Host", "85.90.74.15:8080")
webservice.putheader("Content-type", 'text/xml; charset="utf-8"')
webservice.putheader("Content-length", str(len(xml)))
webservice.endheaders()
webservice.send(xml)

statuscode, statusmessage, header = webservice.getreply()
print "Response: ", statuscode, statusmessage
print "headers: ", header
print webservice.getfile().read()

In right way I should recieve a HTTP/XML answer but when I looked in Wireshark I saw that my sending message is splitted in 2 packets (HTTP) with incorrect checksums in both (incorrect checksum in TCP layer).

My sending packet should look like this:

-> Frame
-> Ethernet
-> IP
-> TCP
-> HTTP
- POST /CallRouter/oam HTTP/1.0\r\n
- Host: 85.90.74.15:8080\r\n
- Content-type: text/xml; charset="utf-8"\r\n
- Content-Length: 312
DATA(<xml>)

But instead I have thoose 2 frames:

PACKET-1
-> Frame
-> Ethernet
-> IP
-> TCP (incorrect ckecksum)
-> HTTP
- POST /CallRouter/oam HTTP/1.0\r\n
- Host: 85.90.74.15:8080\r\n
- Content-type: text/xml; charset="utf-8"\r\n
- Content-Length: 312

PACKET-2
-> Frame
-> Ethernet
-> IP
-> TCP (incorrect ckecksum)
-> HTTP
DATA(<xml>)

2
Contributors
1
Reply
3
Views
9 Years
Discussion Span
Last Post by donnygat
0

Hi everyone!
First, sorry for my bad English!

I have a problem with httplib...
I must send XML contain throu HTTP protocol, and here is my code

import sys
import httplib

xml = """ 
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE Doc SYSTEM "TenorOAM.dtd">
<Doc date="1196693972484" from="10.1.1.180" nid="CMS000001" sid="94" to="85.90.74.15">
<ReqMsg><MsgHead mid="1"/><Cmd><New><ObjPath><Instance otype="Null" oid="Null"/>
<Child otype="Endpoint" id="test"/></ObjPath></New></Cmd></ReqMsg></Doc>"""


webservice = httplib.HTTP("85.90.74.15:8080")
webservice.putrequest("POST", "/CallRouter/oam")
webservice.putheader("Host", "85.90.74.15:8080")
webservice.putheader("Content-type", 'text/xml; charset="utf-8"')
webservice.putheader("Content-length", str(len(xml)))
webservice.endheaders()
webservice.send(xml)

statuscode, statusmessage, header = webservice.getreply()
print "Response: ", statuscode, statusmessage
print "headers: ", header
print webservice.getfile().read()

In right way I should recieve a HTTP/XML answer but when I looked in Wireshark I saw that my sending message is splitted in 2 packets (HTTP) with incorrect checksums in both (incorrect checksum in TCP layer).

My sending packet should look like this:


But instead I have thoose 2 frames:

we had the same problem and after fighting with the code for some time we found out that if we remove the Content-length line:
"webservice.putheader("Content-length", str(len(xml)))"

everything works, cause the length is not only the xml file but also the headers...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.