5

Basic HTTP HTTP request to Merb

 3 years ago
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

advertisements

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

I have to download and parse XML files from http server with HTTP Basic authentication. Now I'm doing it this way: URL url = new URL("http://SERVER.WITHOUT.AUTHENTICATION/some.xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstanc

Auth basic with Jenkins http-request-plugin

I am trying to make a simple POST-request with the "Http Request Plugin". My problem is with getting the credentials to work. I have set a global credential, user:pass. But trying this in my code withCredentials([usernameColonPassword(credential

Rspec Rails 4.2.5 Test Pass Request with Basic HTTP Authentication

The setup is the following. For each http request the manager sends his credentials in the header(name,pw). These get checked against the entries in the db and if they succeed return the desired user object. How is it possible to implement basic http

Sending a FORM POST Request from PHP Using Basic HTTP Authentication

I hope this is a relatively straight forward thing to do, and that my google skills have simply failed me on this occasion. I have a BASIC authentication protected resource which I want to have PHP perform a POST HTTP request against. I have tried in

Basic HTTP authorization header

So, I would lie to set-up a basic HTTP-Authentication using JQuery on the client-side and Node.js on the server side. I have made the following Ajax request on the server side to set the headers: $.ajax({ type: "GET", url: URL_SLACK_SERVER, data

A method to make HTTP requests on Unity iOS?

I need to send HTTP requests with all the standard RESTful methods and access to the body of the request in order to send/receive JSON with it. I've looked into, WebRequest.HttpWebRequest This works almost perfectly, but there are cases where, for ex

How to identify active (long-term) HTTP request URIs?

Imagine a webapp which (sometimes) takes long time to respond to some HTTP (POST/GET/etc) request - how would You find such a request on server side? So far I've used tomcat AccessLogValve to see the "completed" requests, but that doesn't let me

WCF Service with wsHttpBinding - Manipulating HTTP Request Headers

I have been following this tutorial in order to get username authentication with transport security working in my WCF service. The tutorial however refers to using basicHttpBinding which is unacceptable - I require wsHttpBinding. The idea is to have

Any HTTP request module Node.js that works both in the server and in the browser when it comes with Webpack?

I need a request module that works both in the Node.js server and in the client, when bundled with Webpack. My requirements are really basic. I just need to do some HTTP Ajax requests, like get and post. Automatic JSON parsing would be awesome. I'm t

Simulation of an HTTP request method via a browser using the CURL API in PHP

This is very basic, but I am kind of confused where I am going wrong (learning how to implement a RESTful Web Service). The context is, I have a simple simulator.php file that simulates an HTTP request to one of my local PHP files. The local PHP file

Ability to add data to the body of an HTTP request using cURL in PHP?

I would like to add some data to the body of a http request using cURL in PHP. Is this possible? How? I'm sending a HTTP request to a remote server. I have added all the headers I want, but now I need to add some more data to the HTTP body but I cant

How to authenticate an HTTP request that is not POST?

I'm creating a RESTful api, but I don't conceptually understand how to authenticate http requests that aren't POST. For example, I should return a list of objects if I receive a GET request, but I only want to response with that list if the request c

The HTTP request is not allowed with the client authentication scheme 'Ntlm'

While calling a web service I get the following error: The HTTP request is unauthorized with client authentication scheme 'NTLM'. The authentication header received from the server was 'NTLM'. The HTTP request is unauthorized with client authenticati

Can I use PHP SoapClient to parse a SOAP response without making the HTTP request?

I'm currently dealing with an archaic payment processor that makes connecting to their service as hard as possible (including a custom client SSL cert, with a password, plus basic HTTP Auth after that). Long story short, I can't use SoapClient to mak

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK