1
我需要使用三個參數和一個由512字節組成的主體進行發佈。我能得到身體的權利,但我似乎無法得到的參數取:包含多個參數和一個主體的Ruby HTTP Post
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得到一個錯誤。我知道必須有一種方法來分別設置參數和主體,但我似乎無法找到任何參考。
謝謝Dean,我會試試看。我會盡力回答爲什麼問題。這是一款爲實時照明回放和控制而設計的較舊設備。開發人員開發了一個基於管理內存和以最有效的方式存儲數據的API。他的其他UI軟件使用Obj-C,我相信Obj-C的post方法是較低級的,他沒有遇到這個問題。他似乎像這樣將所有的東西串在一起:http://url/set.cgi?dst = RES&type = 11&id = 1&'512_bytes_here',這對他很有用。它似乎不適用於紅寶石... – tsugua