NielMalhotra
NielMalhotra

Reputation: 1375

How to make an HTTP head request with headers in ruby?

I've been trying to use several libraries to make an HTTP HEAD request, but nothing seems to be working.

I've seen some examples, but nothing quite what I want.

Here's the Curl request, now I have to do it in ruby:

curl -XHEAD -H x-auth-user: myusername -H x-auth-key: mykey "url"

Also, this is an HTTPS url, if that makes a difference.

Upvotes: 0

Views: 1114

Answers (1)

Henrique Zambon
Henrique Zambon

Reputation: 1301

Try this:

require 'net/http'

url = 'http://...'
myusename = '...'
mykey = '...'

request = Net::HTTP.new(url, 80)
request.request_head('/', 'x-auth-user' => myusername, 'x-auth-key' => my_key)

Upvotes: 1

Related Questions