mercredi 17 juin 2015

How to write contents to file over iis http or https service

I would like to use http or https to transfer files from client to remote server using windows IIS http or https service. My client machine is Windows8 and my remote server is Windows 2012R2. I had my remote server installed IIS8.5 and create http and https site in the IIS. I started by doing some simple testing.

On client side, I run 3 separate code as below:

#For testing GET request

import httplib
conn = httplib.HTTPSConnection("10.16.8.57", 443)
conn.request("GET", "/test_file.txt")
r1 = conn.getresponse()
print r1.status, r1.reason
data = r1.read()
print data

I can successfully got 200 Ok and the contents in test_file.txt.

#For testing PUT request

BODY = "***filecontents***"
conn = httplib.HTTPSConnection("10.16.8.57", 443)
conn.request("PUT", "/test_file.txt", BODY)
response = conn.getresponse()
print response.status, response.reason

I get error of '405 Method Not Allowed'. Same thing happened for POST request.

On my server side, I only have ISS and has no addition server side code. I would like to know whether I should have a middle tier such as restful service to make it write contents to a file? What is the reason I get '405 Method Not Allow'?




Aucun commentaire:

Enregistrer un commentaire