GodKratos / bittorrent-webui

Automatically exported from code.google.com/p/bittorrent-webui
18 stars 8 forks source link

Adding magnet links to deluge-web fails due to "JSONException: Invalid JSON request content-type: text/plain" #32

Open krichter722 opened 7 years ago

krichter722 commented 7 years ago

Clicking on magnet links on linuxtracker.org usually adds the torrents to deluge-web with this one click and shows a configuration popup (~"Torrent added successfully"). Now the torrent isn't added and JSONException: Invalid JSON request content-type: text/plain is displayed instead of the success message.

experienced with BitTorrent-WebUI+ 0.2.3.0.1-signed.1-signed, Firefox 52.0 and deluge-web 2.0.0.dev6970+5348465+201703142101~ubuntu16.10.1

tic226n commented 7 years ago

I can confirm this issue still persists, as is discussed here[1] with comments from the (deluge) developer regarding a fix.

[1] http://forum.deluge-torrent.org/viewtopic.php?t=54470

GodKratos commented 7 years ago

I've committed a fix for this however Mozilla are refusing to approve latest version of the addon since it uses asynchronous HTTP requests (which it always did). I'll need to rewrite the entire addon in a different way to get it properly approved now.

Gravemind commented 7 years ago

@GodKratos, I still got the error with 0.2.3.1. So, I poked around and added an application/json header in the getSessionID and bittorrent-webui works again with deluge \o/. (But don't trust my fix as-is, first time in a FF plugin)

diff --git a/chrome/content/DelugeDispatcher.js b/chrome/content/DelugeDispatcher.js
index 1f97f0f888..25130685cb 100644
--- a/chrome/content/DelugeDispatcher.js
+++ b/chrome/content/DelugeDispatcher.js
@@ -131,6 +131,7 @@ function DelugeDispatcher() {
        function getSessionID() {
                var request = new XMLHttpRequest();
                request.open( "POST", self.getWebUIAddress() + "/json", false, null, null );
+               request.setRequestHeader("Content-type", "application/json");

                try {
                        request.send(
GodKratos commented 7 years ago

Thanks, I suspected I would need to insert that somewhere else in there but I haven't been able to test this version fully yet to validate that.

aegie commented 7 years ago

dev branch in deluge breaks it, giving an 500 Internal Server error. I'd love to see a fix. Thanks!

GodKratos commented 7 years ago

I've committed the fix above for the deluge dispatcher, give that a try and let me know if it fixes the issue.

Yoposoc commented 7 years ago

@GodKratos I am also using deluge webUI. How can I manually install the plugin from github to use? I've downloaded a zip of the repo but when I try to install it, firefox complains that the add-on is unsigned. I think addon signing can only be done by the creator?

Yoposoc commented 6 years ago

perhaps @Gravemind can help with this... still have this issue. I'm using waterfox now since firefox has killed so many addons.

GodKratos commented 6 years ago

You should be able to download the repo as a zip and then rename it to .xpi to install. I've also stopped using Firefox now in favour of Pale Moon.

Yoposoc commented 6 years ago

@GodKratos In bittorrent-webui-master\releases I see the xpi files, I have to use those right? Is it something else? waterfox let me install bittorrent_webui-0.2.3.1-fx but it does not work with my deluge webui... I get a server did not respond error.