Basic HTTP HTTP request to Merb
source link: https://www.codesd.com/item/basic-http-http-request-to-merb.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Basic HTTP HTTP request to Merb
The Merb Open Source Book has a chapter on authentication. However, the testing an authenticated request section example only shows what you can do for forms based authentication. I have a web service that I want to test with HTTP basic authentication. How would I do that?
After posting my question, I tried a few more things and found my own answer. You can do something like the following:
response = request('/widgets/2222',
:method => "GET",
"X_HTTP_AUTHORIZATION" => 'Basic ' + ["myusername:mypassword"].pack('m').delete("\r\n"))
I may get around to updating the book, but at least this info is here for Google to find and possibly help someone else.
Related Articles
HTTP requests with basic authentication
Auth basic with Jenkins http-request-plugin
Rspec Rails 4.2.5 Test Pass Request with Basic HTTP Authentication
Sending a FORM POST Request from PHP Using Basic HTTP Authentication
Basic HTTP authorization header
A method to make HTTP requests on Unity iOS?
How to identify active (long-term) HTTP request URIs?
WCF Service with wsHttpBinding - Manipulating HTTP Request Headers
Any HTTP request module Node.js that works both in the server and in the browser when it comes with Webpack?
Simulation of an HTTP request method via a browser using the CURL API in PHP
Ability to add data to the body of an HTTP request using cURL in PHP?
How to authenticate an HTTP request that is not POST?
The HTTP request is not allowed with the client authentication scheme 'Ntlm'
Can I use PHP SoapClient to parse a SOAP response without making the HTTP request?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK