Skip to content

Commit

Permalink
Merge pull request #10 from ispras/content-type
Browse files Browse the repository at this point in the history
Added content-type header to html and json responses
  • Loading branch information
mxsnq authored Aug 2, 2022
2 parents 8a5a1b8 + e5f5664 commit 416aa1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scrapypuppeteer/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, url, puppeteer_request, context_id, page_id, **kwargs):
self.cookies = kwargs.pop('cookies')
kwargs.setdefault('body', self.html)
kwargs.setdefault('encoding', 'utf-8')
kwargs.setdefault('headers', {}).setdefault('Content-Type', 'text/html')
super().__init__(url, puppeteer_request, context_id, page_id, **kwargs)


Expand All @@ -64,7 +65,8 @@ class PuppeteerJsonResponse(PuppeteerResponse):

def __init__(self, url, puppeteer_request, context_id, page_id, **kwargs):
self.data = kwargs
super().__init__(url, puppeteer_request, context_id, page_id)
headers = {'Content-Type': 'application/json'}
super().__init__(url, puppeteer_request, context_id, page_id, headers=headers)


class PuppeteerScreenshotResponse(PuppeteerResponse):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='scrapy-puppeteer-client',
version='0.0.5',
version='0.0.6',
description='A library to use Puppeteer-managed browser in Scrapy spiders',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 416aa1c

Please sign in to comment.