错误的错误请求行`m-urlencoded'同时从python发送GET请求到rails

时间:2015-10-15 12:57:53

标签: python ruby-on-rails httprequest actiondispatch

我在python中使用请求包在rails上ping一个localhost url。我的请求标题有四个额外的东西,我附上。

s = Session() 
req = Request('GET',  url, data = payload)
prepped = s.prepare_request(req)
prepped.headers['Content-MD5'] = md5
prepped.headers["Authorization"] = auth_header 
prepped.headers['DATE'] = time.strftime("%Y-%m-%d %H:%M")
resp = s.send(prepped)

payload = {'macaddr': '0c:4d:e9:d4:ef:92'}
md5 = 'tgFTRfbbxwZk3VPsUdDXXQ==\n'
auth_header = 'APIAuth 1005:xJGx1wMxFf/j9AdUpd702VIuMag=\n'

当我在控制器中打印这些东西时,我只得到DATE和MD5而不是其他两件事。这个错误也变坏了 Request-Line m-urlencoded'

1 个答案:

答案 0 :(得分:1)

尝试更改:

md5 = 'tgFTRfbbxwZk3VPsUdDXXQ==\n'
auth_header = 'APIAuth 1005:xJGx1wMxFf/j9AdUpd702VIuMag=\n'

为:

md5 = 'tgFTRfbbxwZk3VPsUdDXXQ==%0a%0a'
auth_header = 'APIAuth 1005:xJGx1wMxFf/j9AdUpd702VIuMag=%0a%0a'