fix: add payload to SendRequestFunction to support POST request#1202
Merged
Pijukatel merged 2 commits intoapify:masterfrom May 20, 2025
Merged
fix: add payload to SendRequestFunction to support POST request#1202Pijukatel merged 2 commits intoapify:masterfrom
payload to SendRequestFunction to support POST request#1202Pijukatel merged 2 commits intoapify:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for POST requests by introducing an optional payload parameter to the send request functionality and updating related tests.
- Updated test cases to handle both GET and POST requests using parameterized inputs.
- Modified the send_request function signatures in both _basic_crawler.py and _types.py to accept an optional payload.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/unit/crawlers/_basic/test_basic_crawler.py | Updated test to include POST requests with payload and JSON response validation |
| src/crawlee/crawlers/_basic/_basic_crawler.py | Added the payload parameter to the send_request function and passed it along to the HTTP client |
| src/crawlee/_types.py | Modified the SendRequestFunction interface to include the payload parameter |
| pytest.param('POST', 'post', 'Hello, world!', id='post send_request'), | ||
| ], | ||
| ) | ||
| async def test_send_request_works(server_url: URL, method: HttpMethod, path: str, payload: None | bytes) -> None: |
There was a problem hiding this comment.
The POST test case is providing a payload as a string ('Hello, world!'), while the function signature indicates a payload of type 'None | bytes'. Ensure type consistency by either converting the string to bytes or updating the type annotation if string payloads are supported.
Pijukatel
approved these changes
May 20, 2025
payload in SendRequestFunction for support POST requestpayload to SendRequestFunction to support POST request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
payloadinSendRequestFunctionfor supportPOSTrequestIssues