tenderlove/mechanize — Issue #181: Problem with basic_auth
Author: DTrierweiler
Created: 2012-01-03 16:33:26+00:00
State: open

This problem didn't exist with 2.0.1.
But now I get an error with the following code:

```
def login
@agent = Mechanize.new
@agent.robots = false # Setting to false, otherwise the login would fail
raise ArgumentError.new("You need to specify an username.") if @username.blank?
raise ArgumentError.new("You need to specify an password.") if @password.blank?
raise ArgumentError.new("Login URL is needed to login.") if @login_url.blank?
@agent.basic_auth(@username, @password)
@agent.get(@login_url)
@agent.robots = true # Setting back to true again, to respect the robots settings
end
```

Error:

```
can't convert nil into String
org/jruby/RubyStringScanner.java:87:in `initialize'
/home/danielt/.rvm/gems/jruby-1.6.5/gems/mechanize-2.1/lib/mechanize/http/www_authenticate_parser.rb:24:in `parse'
/home/danielt/.rvm/gems/jruby-1.6.5/gems/mechanize-2.1/lib/mechanize/http/agent.rb:605:in `response_authenticate'
/home/danielt/.rvm/gems/jruby-1.6.5/gems/mechanize-2.1/lib/mechanize/http/agent.rb:300:in `fetch'
/home/danielt/.rvm/gems/jruby-1.6.5/gems/mechanize-2.1/lib/mechanize.rb:319:in `get'
/data/home/danielt/Code/sinicum-collections/lib/sinicum/collections/search/crawler.rb:29:in `login'
```

Line 29 is @agent.get(@login_url).

I haven't seen anything in the changelog, which points to this...
So thanks for help :)