尝试上载文件时,Rest客户端(Ruby)未设置cookie
如果我尝试使用上述代码发布文件,那么发送的请求将永远不会设置尝试上载文件时,Rest客户端(Ruby)未设置cookie,ruby,http,rest,cookies,rest-client,Ruby,Http,Rest,Cookies,Rest Client,如果我尝试使用上述代码发布文件,那么发送的请求将永远不会设置标题Cookie、用户代理、X-SESSION-ID。。。我用wireshark 我做错了什么?RestClient在检测到文件并将剩余参数视为多部分请求中的其他部分时,会尝试变得聪明。因此,您只需要将内容从标题中分离出来,将其更改为散列 试试这个: require 'rubygems' require 'rest_client' response = RestClient.post "URL",
标题Cookie、用户代理、X-SESSION-ID。。。我用wireshark
我做错了什么?RestClient在检测到文件并将剩余参数视为多部分请求中的其他部分时,会尝试变得聪明。因此,您只需要将内容从标题中分离出来,将其更改为散列
试试这个:
require 'rubygems'
require 'rest_client'
response = RestClient.post "URL",
"myfile" => File.new("/path/to/file"),
"Cookie" => "Name=michal",
"X-SESSION-ID" => "dsafasdfadsfadsfasfdadf",
"User-Agent" => "UNknow",
"connection" => "Keep-Alive"
response = RestClient.post "URL",
{"myfile" => File.new("/path/to/file")},
"Cookie" => "Name=michal",
"X-SESSION-ID" => "dsafasdfadsfadsfasfdadf",
"User-Agent" => "UNknow",
"connection" => "Keep-Alive"