Permalink
Browse files

[REFACTOR] Extracted User-Agent string into its own method (because i…

…t is required as GET parameter for some email providers)
  • Loading branch information...
1 parent 1e95491 commit ba5703811a479183124a32d20b2b712114e7ebd3 @jensb committed Dec 4, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/contacts/base.rb
View
@@ -69,7 +69,11 @@ def password
def skip_gzip?
false
end
-
+
+ def user_agent
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0"
+ end
+
private
def domain
@@ -136,7 +140,7 @@ def remove_cookie(cookie, cookies)
def post(url, postdata, cookies="", referer="")
url = URI.parse(url)
http = open_http(url)
- http_header = { "User-Agent" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0",
+ http_header = { "User-Agent" => self.user_agent,
"Accept-Encoding" => "gzip",
"Cookie" => cookies,
"Referer" => referer,
@@ -158,7 +162,7 @@ def get(url, cookies="", referer="")
url = URI.parse(url)
http = open_http(url)
resp, data = http.get("#{url.path}?#{url.query}",
- "User-Agent" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0",
+ "User-Agent" => self.user_agent,
"Accept-Encoding" => "gzip",
"Cookie" => cookies,
"Referer" => referer

0 comments on commit ba57038

Please sign in to comment.