Allow to set a custom user agent#21
Merged
arj03 merged 1 commit intoiterasdev:masterfrom Mar 10, 2026
Merged
Conversation
Apparently, some SMP providers out there block "python-requests" as a
user agent, I assume because it is contained in popular default WAF
blocklists. Example:
```
In [19]: requests.get("https://smp.soluz.io/iso6523-actorid-upis::0208:0123456", headers={"User-Agent": "python-requests"})
send: b'CONNECT smp.soluz.io:443 HTTP/1.0\r\n\r\n'
send: b'GET /iso6523-actorid-upis::0208:0123456 HTTP/1.1\r\nHost: smp.soluz.io\r\nUser-Agent: python-requests\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n'
reply: 'HTTP/1.1 403 Forbidden\r\n'
header: Server: Microsoft-Azure-Application-Gateway/v2
header: Date: Tue, 10 Mar 2026 08:37:38 GMT
header: Content-Type: text/html
header: Content-Length: 179
header: Connection: keep-alive
Out[19]: <Response [403]>
```
Changing the user agent is the quickest and also cleanest solution:
```
In [18]: requests.get("https://smp.soluz.io/iso6523-actorid-upis::0208:0123456", headers={"User-Agent": "peppol-py"})
send: b'CONNECT smp.soluz.io:443 HTTP/1.0\r\n\r\n'
send: b'GET /iso6523-actorid-upis::0208:0123456 HTTP/1.1\r\nHost: smp.soluz.io\r\nUser-Agent: peppol-py\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Date: Tue, 10 Mar 2026 08:37:31 GMT
header: Content-Type: application/json; charset=utf-8
header: Content-Length: 123
header: Connection: keep-alive
header: Server: Microsoft-HTTPAPI/2.0
Out[18]: <Response [404]>
```
The example is 404 instead of 200 because I did not want to include an
actual participant ID in this commit message.
Collaborator
|
Thanks |
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.
Apparently, some SMP providers out there block "python-requests" as a user agent, I assume because it is contained in popular default WAF blocklists. Example:
Changing the user agent is the quickest and also cleanest solution:
The example is 404 instead of 200 because I did not want to include an actual participant ID in this commit message.