nahi / httpclient

'httpclient' gives something like the functionality of libwww-perl (LWP) in Ruby.
https://github.com/nahi/httpclient
703 stars 290 forks source link

Option to disable warnings #252

Open pinpox opened 9 years ago

pinpox commented 9 years ago

Hello,

Im getting this warning over and over again:

Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.

I'm looking for a way to fix it, but cant find anything. How do I upgrade or disable thje warnings?

Cheers, binaryplease

ghost commented 9 years ago

Hi,

I'm running into the same warning. Unfortunately for me httpclient is setting and getting the cookies using a cookie store and I cannot simply call Cookie#dot_domain as suggested:

cookie_file = Tempfile.new('cookie_jar.txt')
clnt = HTTPClient.new
clnt.set_cookie_store(cookie_file)
clnt.get(URL1)

clnt.post(URL2) # cookie use throws warning 'Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.'

I would say it's preferrable to set a flag in the library to allow the client to use Cookie#dot_domain under the hood:

client.allow_dot_domain_cookie = true

Bob

pdostal commented 9 years ago

I have similar problem. I need to allow dot_domain but I don't know how.

dazza-codes commented 9 years ago

:-1: this is annoying.

Using a Faraday::Adapter::HttpClient that does nothing to configure cookie management in httpclient, i.e. https://github.com/lostisland/faraday/blob/master/lib/faraday/adapter/httpclient.rb

So this warning is a message for httpclient by httpclient? Why not just fix it in httpclient? The culprit line is at https://github.com/nahi/httpclient/blob/master/lib/httpclient/cookie.rb#L197

Please wrap it to use @@warned so it can be toggled off, see

dazza-codes commented 9 years ago

PR https://github.com/nahi/httpclient/pull/268

elifoster commented 9 years ago

Okay, what confuses me about this is I used to get it when testing/using my MediaWiki::Butt gem, but it stopped so long ago and I don't remember how I may have "fixed" it. And even still, it happens for another user using basically identical code to mine.

vnazarenko commented 9 years ago

O totally agree, is there any way to remove this annoying warning?

bootstraponline commented 7 years ago
class WebAgent
  class Cookie < HTTP::Cookie
    def domain
      self.original_domain
    end
  end
end

^ is how I removed the warning. It'd be nice if there was an option to ignore the warning.