Why there is different response in python and ruby mechanize for the same HTTP GET request?
Python:
def send(cls, url, values = None, method = 'GET', header={}):
print(url)
c = cls()
data = None
context = ssl._create_unverified_context()
if values is not None:
# data = urllib.parse.urlencode(values)
# data = data.encode('utf-8') # data should be bytes
data = json.dumps(values)
data = data.encode('utf-8')
if data is None:
c.request = urllib.request.Request(url)
else:
c.request = urllib.request.Request(url, data)
c.request.add_header('Content-Type', 'application/json')
for key, value in header.items():
c.request.add_header(key,value)
c.request.method = method
# print(c.request.get_header('Content-Type'))
try:
c.response = urllib.request.urlopen(c.request, context=context)
except urllib.error.HTTPError as e:
c.response = e
# print(e.hdrs)
return c
resp = HTTPSender.send("https://10.5.110.143/__api__/logon/704383e332d46036369a510e2673fe94?method=144", method="GET")
print(resp.body)
Output :
{ "message": "The method is not allowed for the requested URL." }
Ruby mechanize:
@agent=Mechanize.new
$resp = .get("https://10.5.110.143/__api__/logon/704383e332d46036369a510e2673fe94?method=144")
puts $resp.content
Output:
405 => Net::HTTPMethodNotAllowed for https://10.5.110.143/api/logon/9c7ca3f5 34ea1c8a5bfe64d7cf08797a?method=144 -- unhandled response
Is it something expected?