From 78df1dc8bcbef23a2dee7c5e5c5683d4e1cebbf3 Mon Sep 17 00:00:00 2001 From: Jessica Dillon & Jessica Lynn Suttles Date: Mon, 1 Jul 2013 16:47:28 -0700 Subject: [PATCH] sets Microformats2::Parser#http_headers on initialize --- lib/microformats2/parser.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/microformats2/parser.rb b/lib/microformats2/parser.rb index 1238690..6ee4e6e 100644 --- a/lib/microformats2/parser.rb +++ b/lib/microformats2/parser.rb @@ -2,13 +2,17 @@ module Microformats2 class Parser attr_reader :http_headers, :http_body - def parse(html, headers={}) + def initialize + @http_headers = {} + end + + def parse(html, headers=@http_headers) html = read_html(html, headers) document = Nokogiri::HTML(html) Collection.new(document).parse end - def read_html(html, headers={}) + def read_html(html, headers=@http_headers) open(html, headers) do |response| @http_headers = response.meta if response.respond_to?(:meta) @http_body = response.read