Skip to content

Commit

Permalink
Refactor warcmiddleware.py
Browse files Browse the repository at this point in the history
  • Loading branch information
odie5533 committed Oct 25, 2013
1 parent ac98dc7 commit bc63a1c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions warcmiddleware.py
@@ -1,9 +1,9 @@
import urlparse
from cStringIO import StringIO

import scrapy.http
import twisted.web.http
from scrapy.utils.httpobj import urlparse_cached
import scrapy.http

import warcrecords

Expand Down Expand Up @@ -34,7 +34,7 @@ def __init__(self):
Follows most of the code from scrapy/core/downloader/webclient.py
"""
def warcrec_from_scrapy_request(self, request):
def _warcrec_from_scrapy_request(self, request):
headers = request.headers
body = request.body

Expand Down Expand Up @@ -66,7 +66,7 @@ def warcrec_from_scrapy_request(self, request):
tofix: Handle response.status codes
"""
def warcrec_from_scrapy_response(self, response):
def _warcrec_from_scrapy_response(self, response):
# Everything is OK.
resp_str = "HTTP/1.0 " + str(response.status) + " OK\r\n"
resp_str += response.headers.to_string()
Expand All @@ -76,10 +76,10 @@ def warcrec_from_scrapy_response(self, response):
return warcrecords.WarcResponseRecord(url=response.url, block=resp_str)

def process_request(self, request, spider):
record = self.warcrec_from_scrapy_request(request)
record = self._warcrec_from_scrapy_request(request)
record.write_to(self.fo)

def process_response(self, request, response, spider):
record = self.warcrec_from_scrapy_response(response)
record = self._warcrec_from_scrapy_response(response)
record.write_to(self.fo)
return response # return the response to Scrapy for further handling

0 comments on commit bc63a1c

Please sign in to comment.