lgallard / qBittorrent-Controller

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

add torrent fails with Apache reverse proxy #232

Closed xifer closed 4 years ago

xifer commented 4 years ago

Looks like Content-Type is added twice and the reverse proxy (Apache in my case) merges the fields. Had to bust out Wireshark for this one :). Attached HTTP ASCII of the captures.

Could try not setting it in MainActivity and check to see if adding torrents still works?

https://github.com/lgallard/qBittorrent-Controller/blob/32cd827d267da8d1a6aec51347845f093e0ed59d/app/src/main/java/com/lgallardo/qbittorrentclient/MainActivity.java#L2349 and https://github.com/lgallard/qBittorrent-Controller/blob/32cd827d267da8d1a6aec51347845f093e0ed59d/app/src/main/java/com/lgallardo/qbittorrentclient/MainActivity.java#L2449

https://github.com/lgallard/qBittorrent-Controller/blob/32cd827d267da8d1a6aec51347845f093e0ed59d/app/src/main/java/com/lgallardo/qbittorrentclient/UrlsMultipartRequest.java#L62

Work-around for Apache: RequestHeader edit Content-Type ",.+" ""

Nginx unaffected, sends Content-Type twice like app_working.txt.

app_proxy_broken.txt

browser_proxy_working.txt

app_working.txt

lgallard commented 4 years ago

@xifer there are two different methods:

  1. addTorrentFileAPI7: This is used when adding torrents files (downloaded .torrent files)
  2. addTorrentUrls: This one is for adding torrents using urls (torrent and magnet links)
xifer commented 4 years ago

@lgallard Right, and they both use UrlsMultipartRequest which sets the content-type via an overridden callback getBodyContentType? Then params.put("Content-Type", urlContentType); in each of the addTorrent functions adds it a second time.

Anyways I think it would be easy to comment out those two params.put("Content-Type", urlContentType); lines and test to see if the addTorrent functions still work (ie. getBodyContentType gets called internally in Request<NetworkResponse> (UrlsMultipartRequest's parent) and adds the content-type header field).

lgallard commented 4 years ago

@xifer I see your point!! I'll be addressing this in the next release!

lgallard commented 4 years ago

Done!

lgallard commented 4 years ago

Release version 4.8.5 with this fixes!