dgtlmoon/changedetection.io

Notification headers not compatible with spaces

Closed this issue · 8 comments

Describe the bug
I'm trying to record a few changes to a website in an InfluxDB instance I have, however I can't correctly send a HTTP request due to how the headers need to be formatted when sending them to a bucket in InfluxDB (InfluxDB docs here).

Using tcpdump we can see that:
post://influxdb:8086/api/v2/write?org=testorg&bucket=testbucket&+Authorization=Token ZEXml2eZNVfJQI_9TMTp0Jlli5== generates a HTTP request with the following headers:

POST /api/v2/write?org=testorg&bucket=testbucketHTTP/1.1
Host: influxdb:8086
User-Agent: python-requests/2.32.3
Accept-Encoding: gzip, deflate, br
Accept: */*
Connection: keep-alive
authorization: Token+ZEXml2eZNVfJQI_9TMTp0Jlli5==
Content-Length: 67

(I watched the network adapter on the InfluxDB instance with tcpdump -i any -A to get this result)

The server, in turn, replies with:

HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8                                                                                                                                               X-Influxdb-Build: OSS
X-Influxdb-Version: v2.7.10
X-Platform-Error-Code: unauthorized
Date: Sat, 26 Oct 2024 15:59:41 GMT
Content-Length: 55 

and on the console:

ts=2024-10-26T15:59:41.903549Z lvl=info msg=Unauthorized log_id=0sU2G2Nl000 error="token required"

So we can assume that the format was not recognized by InfluxDB.

Version
v0.46.02

To Reproduce

  1. Create a notification that uses spaces and sensitive casing and point to a InfluxDB instance
  2. tcpdump -i any -A in the InfluxDB instance
  3. Verify that spaces in the header become +

Expected behavior
Notification headers spaces should be the valid character instead of + (which valid only on URIs)

Desktop (please complete the following information):

  • OS: Linux
  • Browser firefox
  • Version 131.0.3 (64-bit)

Note: I edited this description to better reflect the actual problem, we talked about case sensitiveness but it is confirmed that this is not an issue when it comes to HTTP headers.

So it's converting Authorization to authorization right?

Yes, plus the space being encoded as +

Ah ok, thanks for the report

@guicattani btw

There is an RFC that addresses the case sensitivity of HTTP headers. According to RFC 7230 (which is part of the HTTP/1.1 specifications), HTTP header field names are case-insensitive. This means that HTTP headers are not case-sensitive.

The relevant section is:

RFC 7230, Section 3.2:
Each header field consists of a case-insensitive field name followed by a colon (":"), optional whitespace, and the field value.

This RFC clarified that HTTP header field names are case-insensitive, so headers like Content-Type, content-type, and CoNtEnT-TyPe should be treated as equivalent.

If you're interested in the formal source, you can refer to RFC 7230 for more details about this behavior.

Yes, plus the space being encoded as +

Therefor, this is the only problem right?

You are right! Thanks for the trouble of looking into the case sensitiveness! :)

I tested a payload with authorization and it worked fine.
Tested using curl

* Connected to influxdb (172.21.0.8) port 8086 (#0)
> POST /api/v2/write?org=testorg&bucket=testbucket HTTP/1.1
> Host: influxdb:8086
> User-Agent: curl/7.88.1
> authorization:Token DALO0Uuro22MnJFNjMetyKzoIMCLn6SBV5BEAq-UyUL7roOKTTd00uX9_bsc_Rrn9HOgnI89sIdN1d0l8diGPw==
> Content-Type: text/plain; charset=utf-8
> Accept: application/json
> Content-Length: 231
>
< HTTP/1.1 204 No Content
< X-Influxdb-Build: OSS
< X-Influxdb-Version: v2.7.10
< Date: Sun, 27 Oct 2024 15:59:42 GMT
<
* Connection #0 to host influxdb left intact 

(No Content is what we want when communicating with InfluxDB)

Therefore yes, it's only the + symbol that is the issue

Using curl

* Connected to influxdb (172.21.0.8) port 8086 (#0)                                                                                                                                                                                                 [24/392]> POST /api/v2/write?org=testorg&bucket=testbucket HTTP/1.1
> Host: influxdb:8086
> User-Agent: curl/7.88.1
> authorization:Token+DALO0Uuro22MnJFNjMetyKzoIMCLn6SBV5BEAq-UyUL7roOKTTd00uX9_bsc_Rrn9HOgnI89sIdN1d0l8diGPw==
> Content-Type: text/plain; charset=utf-8
> Accept: application/json
> Content-Length: 231
>
< HTTP/1.1 401 Unauthorized
< Content-Type: application/json; charset=utf-8
< X-Influxdb-Build: OSS
< X-Influxdb-Version: v2.7.10
< X-Platform-Error-Code: unauthorized
< Date: Sun, 27 Oct 2024 15:59:31 GMT
< Content-Length: 55
<
* Connection #0 to host influxdb left intact
{"code":"unauthorized","mescurl -v --request POST \ss"}

Thanks for the really solid report, that should be fixed in the :dev image, feel free to try it once its built in a few minutes

Glad that I could give a little back to this great project! ❤️
Test it and it returned 204 No Content as expected! Thanks for the quick fix!