lgallard / qBittorrent-Controller

qBittorrent Controller - An Android app for controlling qBittorrent servers
MIT License
286 stars 58 forks source link

extra colon in Content-Type header #231

Closed xifer closed 4 years ago

xifer commented 4 years ago

qBittorrent (+ apache rerverse proxy) really doesn't like that colon after Content-Type on this line:

https://github.com/lgallard/qBittorrent-Controller/blob/986fea474fb8cbaee8292279e37cb8a460e47296/app/src/main/java/com/lgallardo/qbittorrentclient/MainActivity.java#L1301

The request headers for content-type ends up looking like this: Content-Type:: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded; charset=UTF-8

params.put("Content-Type:", "application/x-www-form-urlencoded"); should be params.put("Content-Type", "application/x-www-form-urlencoded");

Same issue here I think:

https://github.com/lgallard/qBittorrent-Controller/blob/0cb3045c5a414bc93b9b6461b88fbdbaa4269f8e/app/src/main/java/com/lgallardo/qbittorrentclient/NotifierService.java#L275

qBittorrent error in log: bool Http::RequestParser::parsePostMessage(const QByteArray&) unknown content type: ": application/x-www-form-urlencoded, application/x-www-form-urlencoded; charset=UTF-8" Http::RequestParser::ParseResult Http::RequestParser::doParse(const QByteArray&) message body parsing error

apache access log: x.x.x.x - - [04/Mar/2020:10:42:01 -0800] "POST /api/v2/auth/login HTTP/1.1" 400 -

xifer commented 4 years ago

Might not be useful to anyone but here's a work-around for apache reverse proxies:

SetEnvIf Content-Type "^:" MY_ContentTypeFix RequestHeader set Content-Type "application/x-www-form-urlencoded" ENV=MY_ContentTypeFix

lgallard commented 4 years ago

@xifer nice catch!! Maybe this is causing the reverse-proxy issues reported in #178

I'm going to fix it and release a new version this week. By the way, thanks for sharing the workaround in Apache!

xifer commented 4 years ago

For what it's worth nginx reverse proxy along with HTTPS seemed to work just fine for me without that qbittorrent error in the log.

Regardless, this removed the extra "Content-Type:" header when I was testing it.

proxy_hide_header Content-Type:;

And a note, if you're on Linux and running an HTTP/S on the proxy server then proxying via plain HTTP to the qbittorrent webui port (ie. port 8080) you can stop qbittorrent then run 'nc -l -p 8080' (translation: netcat listen on port 8080) and when you do a request via the app or a browser you can see the full HTTP request including the headers.

Tcpdump on Linux and Wireshark on Windows can be helpful too but I rarely remember the incantations to get those working the first time, they're pretty complicated/powerful.

lgallard commented 4 years ago

Release version 4.8.5 with this fixes!