Tag: http put

使用ruby Net:HTTP API将文件上载到远程apache服务器失败,发生409冲突

下面是一个将文件从本地文件系统上传到远程Apache服务器的程序。 该程序以409冲突错误结束。 有什么建议我做错了吗? 我在httpd.conf中启用了DAV并提供了所有必要的权限,但我仍然没有运气。 如果需要,我可以发布httpd.conf。 这是代码: BOUNDARY = “AaB03xZZZZZZ11322321111XSDW” uri = URI.parse(“http://localhost/dropbox/”) file = “/tmp/KEYS.txt” http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Put.new(uri.request_uri) request.body_stream=File.open(file) request[“Content-Type”] = “multipart/form-data” request.add_field(‘Content-Length’, File.size(file)) request.add_field(‘session’, BOUNDARY) response=http.request(request) puts “Request Headers: #{request.to_hash.inspect}” puts “Sending PUT #{uri.request_uri} to #{uri.host}:#{uri.port}” puts “Response #{response.code} #{response.message}” puts “#{response.body}” puts “Headers: #{response.to_hash.inspect}” 它的输出: Request Headers: {“accept”=>[“*/*”], “host”=>[“localhost”], […]