Skip to content

Commit

Permalink
Added support for custom headers in fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
nerakdon committed May 19, 2014
1 parent 3ea3404 commit 4ab8b98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/museum/methods.rb
@@ -1,5 +1,6 @@
class String
def fetch
def fetch(headers = {})
headers['User-Agent'] = 'GemVein Museum'
require 'net/http'
require 'net/https'

Expand All @@ -8,7 +9,7 @@ def fetch
http.use_ssl = (uri.scheme == "https")
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(uri.request_uri, {'User-Agent' => 'GemVein Museum'})
request = Net::HTTP::Get.new(uri.request_uri, headers)

response = http.request(request)
response.body
Expand Down
4 changes: 2 additions & 2 deletions museum.gemspec
Expand Up @@ -2,11 +2,11 @@
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: museum 0.1.2 ruby lib
# stub: museum 0.1.3 ruby lib

Gem::Specification.new do |s|
s.name = "museum"
s.version = "0.1.2"
s.version = "0.1.3"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
Expand Down

0 comments on commit 4ab8b98

Please sign in to comment.