1

How can I set a header in Ruby HTTP Client? I want my header to be like

client = HTTPClient.new
url = "https://dummyurl.com"
headers = { "id": "x", "pass": "y" }
response = client.get(url)

how should i put the headers? thank you

1 Answer 1

1

.get has a signature of

get(uri, query = nil, extheader = {}, &block)

You pass either an object or an array of objects as extheader to set any additional headers, e.g.

response = client.get(url, nil, headers)

per your example.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.