Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with ZAPI proxy mode in response handling #117

Merged

Conversation

starrify
Copy link
Contributor

@starrify starrify commented Feb 2, 2024

There's no exact equivalence of X-Crawlera-Version in ZAPI. The Zyte-Request-Id header seems to be the closest match yet it does not cover certain types of errors like authentication errors (e.g. curl -v https://example.com/ -x $API_URL).

Thus zyte-error-type is introduced as well to also cover such scenarios.

There's no exact equivalence of `X-Crawlera-Version` in ZAPI. The
`Zyte-Request-Id` header seems to be the closest match yet it does not
cover certain types of errors like authentication errors (e.g.
`curl -v https://example.com/ -x $API_URL`).

Thus `zyte-error-type` is introduced as well to also cover such
scenarios.
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (677b936) 100.00% compared to head (a0811a5) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #117   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          295       295           
=========================================
  Hits           295       295           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -93,25 +90,34 @@ def _assert_enabled(self, spider,
crawler = self._mock_crawler(spider, settings)
mw = self.mwcls.from_crawler(crawler)
mw.open_spider(spider)
httpproxy = HttpProxyMiddleware.from_crawler(crawler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most test changes are to apply this, i.e. run the Scrapy middleware not just the proxy middleware. They are not specifically needed for this change in the latest iteration, but I think it is best to keep the changes. They e.g. pointed to some bad proxy URLs (missing : after the API key).

@Gallaecio Gallaecio requested review from kmike and wRAR February 2, 2024 15:24
@Gallaecio Gallaecio merged commit cbe4a8e into scrapy-plugins:master Feb 22, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants