just to answer my own question ....
I've managed to get basic HTTP authentication using OpenURI ... so
yeah ... ttrying to put in an 'Authorization' header in the download()
method somehow doesn't work.
Could be that I've done something wrong (see below code) ... but I'll
use OpenURI for now.
... would have been really nice to use downloads() threading abstraction :)
Etienne
On Wed, Nov 12, 2008 at 1:54 PM, e deleflie <[EMAIL PROTECTED]> wrote:
> I've been trying, without success, to include a basic HTTP
> authentication header in my download() calls (to my Rails server).
> This is what the code looks like:
>
> headers = {}
> headers['Authorization'] = 'Basic ' +
> Base64.encode64("[EMAIL PROTECTED]()}:[EMAIL PROTECTED]()}").chop
> # run the download
> download "#{$SITE_URL}/badaboo/new.xml", :method =>
> "POST", :headers => headers do |result|
> # if it passes then goto the next screen.
> @status.text = "The result is #{result.response.body}"
> end
>
>
> Its not working... authentication is not happening, and from what I
> can tell, the built-in Rails 2.0 block is not being called:
>
> authenticate_or_request_with_http_basic do |user_name, password|
> # this block never gets called.
> end
>
> Has anyone tried to do this? I'm using Mongrel (without Apache) in a
> development environment (which should theoretically work fine). I'm
> wondering if the download() call does things to the header ... maybe I
> should fall back to OpenURI ...
>
> Etienne
>