53 def sendMessage(host,port,dbsInst,userInput,page,limit,xml=0,case='on',iface='dd',details=0,cff=0,debug=0):
55 Send message to server, message should be an well formed XML document.
61 input=urllib.quote(userInput)
63 httplib.HTTPConnection.debuglevel = 1
64 print(
"Contact",host,port)
66 if host.find(
"http://")!=-1:
68 if host.find(
"https://")!=-1:
70 host=host.replace(
"http://",
"").
replace(
"https://",
"")
71 if host.find(
":")==-1:
74 if host.find(
"/")!=-1:
77 prefix_path=
'/'.
join(hs[1:])
78 if host.find(
":")!=-1:
79 host,port=host.split(
":")
83 http_conn = httplib.HTTPS(host,port)
85 http_conn = httplib.HTTP(host,port)
88 path=
'/aSearch?dbsInst=%s&html=0&caseSensitive=%s&_idx=%s&pagerStep=%s&userInput=%s&xml=%s&details=%s&cff=%s&method=%s'%(dbsInst,case,page,limit,input,xml,details,cff,iface)
90 path=
"/"+prefix_path+path[1:]
91 http_conn.putrequest(
'POST',path)
92 http_conn.putheader(
'Host',host)
93 http_conn.putheader(
'Content-Type',
'text/html; charset=utf-8')
94 http_conn.putheader(
'Content-Length',
str(len(input)))
95 http_conn.endheaders()
98 (status_code,msg,reply)=http_conn.getreply()
99 data=http_conn.getfile().
read()
100 if debug
or msg!=
"OK":
102 print(http_conn.headers)
103 print(
"*** Send message ***")
105 print(
"************************************************************************")
106 print(
"status code:",status_code)
107 print(
"message:",msg)
108 print(
"************************************************************************")