Skip to content

Allow to set a custom user agent#21

Merged
arj03 merged 1 commit intoiterasdev:masterfrom
raphaelm:user-agent
Mar 10, 2026
Merged

Allow to set a custom user agent#21
arj03 merged 1 commit intoiterasdev:masterfrom
raphaelm:user-agent

Conversation

@raphaelm
Copy link
Collaborator

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.

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.
@raphaelm raphaelm marked this pull request as draft March 10, 2026 08:40
@raphaelm raphaelm marked this pull request as ready for review March 10, 2026 08:46
@raphaelm raphaelm changed the title Allow to set a custom user agent. Allow to set a custom user agent Mar 10, 2026
@arj03 arj03 merged commit 5f9cfd4 into iterasdev:master Mar 10, 2026
2 checks passed
@arj03
Copy link
Collaborator

arj03 commented Mar 10, 2026

Thanks

@raphaelm raphaelm deleted the user-agent branch March 10, 2026 10:10
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.

2 participants