我需要使用三个参数和一个由 512 个字节组成的正文进行发布。我可以得到正确的身体,但我似乎无法获得要采用的参数:
require 'net/http'
@ip_address = Array['cueserver.dnsalias.com']
@cueserver = 0
@playback = 'p1'
def send_cuescript(data)
params = {'id' => '1', 'type' => "20",'dst' => 'RES' }
begin
url = URI.parse('http://'+ @ip_address[@cueserver] + '/set.cgi')
http = Net::HTTP.new(url.host, url.port)
response, body = http.post(url.path, params, data)
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
end
response_array = []
puts 'got this value: ' + response.to_s
response.body.each_byte { |e| response_array.push(e.to_s(16))}
end
data_array = Array.new(512, "\x80")
send_cuescript(data_array.join)
我收到来自 initialize_http_header 的错误。我知道必须有一种方法可以分别设置参数和主体,但我似乎找不到任何对此的参考。