Ticket #2256 (closed Bugs: fixed)

Opened 6 years ago

Last modified 5 years ago

[PATCH] AJAX reload fails when proxy is being used

Reported by: gregmac Assigned to: gregmac
Priority: minor Milestone: 2.3
Component: Web interface Version: 2.3-branch
Keywords: Cc:
Confirmation: Pending Distro:
Backend Engine: All Distro Ver:
Backend Ver: SVN Revision (if applicable): 4873

Description

Original source: http://www.freepbx.org/forums/viewtopic.php?t=2683

According to the posts, the reload going through a (eg, squid) proxy fails. According to http://forum.mootools.net/viewtopic.php?pid=20400 this is because of a 0-length body.

I cannot reproduce this myself because I don't have any systems running with a proxy.

Attachments

freepbx-2.4.0-json-fix.patch (2.7 kB) - added by kRutOn on 02/22/08 16:28:57.
Fixes proxies that want to mangle any text/html content. (breaks JSON responses)

Change History

08/09/07 17:25:17 changed by gregmac

  • confirmation changed from Need Feedback to Need testing.

If the problem is indeed a 0-length body on the POST request, here is a proposed patch:

If you are experiencing this issue, please try it and post here if it works or not.

Index: amp_conf/htdocs/admin/views/freepbx_reload.php
===================================================================
--- amp_conf/htdocs/admin/views/freepbx_reload.php      (revision 4873)
+++ amp_conf/htdocs/admin/views/freepbx_reload.php      (working copy)
@@ -53,7 +53,8 @@

                                $.ajax({
                                        type: 'POST',
-                                       url: "<?php echo $_SERVER["PHP_SELF"]; ?>?handler=reload",
+                                       url: "<?php echo $_SERVER["PHP_SELF"]; ?>",
+                                       data: "handler=reload",
                                        dataType: 'json',
                                        success: function(data) {
                                                if (data.status) {

08/13/07 10:09:15 changed by rjch

The fix above has worked very nicely for me on two separate Asterisk 1.4 boxes. I'm running Firefox version 2.0.0.6 under both Windows and Linux. I can also confirm that before I applied the fix, the problem was not occurring when I disabled my proxy.

08/13/07 11:31:33 changed by p_lindheimer

update from forum. httplite has the same issue. The fix does not fix it. We can apply this fix for now to address the proxy issue. But we should investigate if there is anything that can address httplite at some point. Might be better to close this ticket when the fix is applied and open a new ticket against httplite which is more of a corner case since it is not so common.

08/15/07 19:03:04 changed by p_lindheimer

  • summary changed from AJAX reload fails when proxy is being used to [PATCH] AJAX reload fails when proxy is being used.

08/15/07 22:54:41 changed by gregmac

  • status changed from new to closed.
  • confirmation changed from Need testing to Pending.
  • resolution set to fixed.

With the above patch, this works fine with Firefox 2.0.0.6/linux and the following configurations:

  • Direct to Apache 2.2.3-3.2
  • Direct to lighttpd 1.4.16-1
  • Via squid 3.0PRE5-5 to Apache 2.2.3-3.2
  • Via squid 3.0PRE5-5 to lighttpd 1.4.16-1
  • Via squid 2.6.5-4ubuntu2 to Apache 2.2.3-3.2
  • Via squid 2.6.5-4ubuntu2 to lighttpd 1.4.16-1

squid was running on a Ubuntu Feisty 7.04 system, Apache/lighttpd (and FreePBX) on a Debian lenny (testing) system.

I have commited this patch in [4887].

If you are still experiencing this bug after applying this patch, or running from 2.3 branch svn >= 4887, then please do the following:

  • Install the Firebug extension for Firefox
  • Navigate to a FreePBX page with the reload button active
  • Enable/open Firebug by clicking on the gray circle (looks kind of like a screw) or the green circle with a checkbox in the bottom right corner of Firefox.
  • Make sure the "Console" tab is visible in Firebug, and then do the reload.
  • You should see a line like "POST ..../admin/config.php". Expand it, and you should see "Headers" and "Response"
  • Reopen this ticket, and include the following information in the comment:
    • The "Headers" and "Response" output from Firebug
    • The version of FreePBX (svn revision number, if using SVN)
    • Other relevant details: web server/version, proxy type/version (if using a proxy)
    • Anything else about your setup that would be useful (eg, VPN links or any other strange network setups)

Without this information, I simply cannot do anything with this bug since I am totally unable to reproduce it. For now I am considering this bug fixed.

Thanks.

02/22/08 16:28:57 changed by kRutOn

  • attachment freepbx-2.4.0-json-fix.patch added.

Fixes proxies that want to mangle any text/html content. (breaks JSON responses)

(follow-up: ↓ 7 ) 02/22/08 16:29:47 changed by kRutOn

It looks like the problem is that the response Content-type for JSON is "text/html" when it should be something like "application/json" so proxies don't mangle it.

(in reply to: ↑ 6 ) 02/22/08 16:32:32 changed by kRutOn

Replying to kRutOn:

It looks like the problem is that the response Content-type for JSON is "text/html" when it should be something like "application/json" so proxies don't mangle it.

Actually, I will open a new bug because there appears to be two issues at hand and one is fixed already.