fix(blocks): Error messages from SendWebRequestBlock use the requested translated IP instead of the orignal URL (#10009)

### Changes 🏗️

Keep the original URL when an HTTP error occurs in
`SendWebRequestBlock`.

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] Test sending POST request on a web that doesn't support POST
request using `SendWebRequestBlock`.
This commit is contained in:
Zamil Majdy
2025-05-22 16:46:01 +01:00
committed by GitHub
parent 8f1b3eb8ba
commit 1b81a7c755

View File

@@ -247,6 +247,7 @@ class Requests:
# Pin the URL if untrusted
hostname = url.hostname
original_url = url.geturl()
if not is_trusted:
url = pin_url(url, ip_addresses)
@@ -277,6 +278,12 @@ class Requests:
**kwargs,
)
# Replace response URLs with the original host for clearer error messages
if url.hostname != hostname:
response.url = original_url
if response.request is not None:
response.request.url = original_url
if self.raise_for_status:
response.raise_for_status()