2016-02-11 102 views
1
curl --request PROPFIND --url "http://carddav.mail.aol.com/home/[email protected]/Contacts/" --header "Content-Type: text/xml" --header "Depth: 1" --data '<A:propfind xmlns:A="DAV:"><A:prop><A:getetag /><D:address-data xmlns:D="urn:ietf:params:xml:ns:carddav"/></A:prop></A:propfind>' --header "Authorization: Bearer fjskdlfjds" 

Net :: HTTP中是否有一個特殊的方法允許propfind命令?如何在Ruby中運行此curl命令?

回答

0
Net::HTTP::Propfind 

下面是一個例子:

uri = URI.parse('http://example.com') 
http = Net::HTTP.new(uri.host, uri.port) 
request = Net::HTTP::Propfind.new(uri.request_uri) 

# Set your body (data) 
request.body = "Here's the body." 

# Set your headers: one header per line. 
request["Content-Type"] = "application/json" 

response = http.request(request) 
+0

謝謝!我不認爲這會很簡單。 –

+0

不客氣。這對我來說並不簡單...... –