如果我使用Python(带请求),如下所示: -
r = requests.post("http://httpbin.org/post","Post from Python")
r.text
u'{\n "args": {}, \n **"data": "Post from Python"**, \n "files": {}, \n **"form": {}**, \n "headers": {\n "Accept": "*/*", \n "Accept-Encoding": "gzip, deflate", \n "Connect-Time": "1", \n "Connection": "close", \n "Content-Length": "16", \n "Host": "httpbin.org", \n "Total-Route-Time": "0", \n "User-Agent": "python-requests/2.3.0 CPython/2.7.8 CYGWIN_NT-6.1-WOW64/1.7.32(0.274/5/3)", \n "Via": "1.1 vegur", \n "X-Request-Id": "7e8907d6-b5ad-4715-99e2-eacba921cf7e"\n }, \n "json": null, \n "origin": "92.28.252.59", \n "url": "http://httpbin.org/post"\n}'
如何从Ruby获得相同的结果?具体来说,我想知道如何从Ruby发布" Post"进入响应的同一个领域?
例如,如果我使用rest-client,那么"发布来自Ruby"消息在响应的不同字段中出现,而不是上面的Python案例:
RestClient.post("httpbin.org/post","Post from Ruby")
=> "{\n \"args\": {}, \n \"data\": \"\", \n \"files\": {}, \n \"form\": {\n \"Post from Ruby\": \"\"\n },... (truncated)
我也尝试过nestful和httpclient并看到相同的行为