Bug 153901

Summary: POST queries twice with <body onunload="something_with_XMLHttpRequest();">
Product: [Applications] konqueror Reporter: Bastiaan Welmers <haasje>
Component: khtmlAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: kde
Priority: NOR    
Version: 3.5   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:

Description Bastiaan Welmers 2007-12-12 11:55:06 UTC
Version:            (using KDE KDE 3.5.7)
Installed from:    Debian testing/unstable Packages
OS:                Linux

For some reason, when opening a page with the following javascript included in the html head: http://www.welmers.net/~bastiaan/XmlHttpRequest.js

and with body tag:

<body onunload="loadXMLDoc('/deletelock.php?item=XXX');">

and submitting a <form method="POST">

it happens that konqueror seems to POST the page _twice_, one before the XMLHttpRequest en one time after, according to the server logs:

::1 - - [12/Dec/2007:11:11:29 +0100] "POST /lid.php HTTP/1.1" 200 1031 "http://localhost/lid.php" "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.7 (like Gecko) (Debian)"
::1 - - [12/Dec/2007:11:11:29 +0100] "GET /deletelock.php?item=XXX HTTP/1.1" 200 - "http://localhost/lid.php" "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.7 (like Gecko) (Debian)"
::1 - - [12/Dec/2007:11:11:29 +0100] "POST /lid.php HTTP/1.1" 200 9245 "http://localhost/lid.php" "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.7 (like Gecko) (Debian)"

As far as I know, a browser should never POST an item twice without permission of the user...
Comment 1 Bastiaan Welmers 2007-12-12 11:59:48 UTC
The title of this bug is wrong: it states "onload", it should be "onunload", so it's about the onunload event triggered when exiting the html page.
Comment 2 Bastiaan Welmers 2007-12-12 12:15:54 UTC
The following example will trigger the bug:
http://www.welmers.net/~bastiaan/konqueror_xmlhttprequest_bug.html

It should be installed on your own web server (so you can see the server logs, or use a traffic sniffer) with the following files:
http://www.welmers.net/~bastiaan/XmlHttpRequest.js
http://www.welmers.net/~bastiaan/XmlHttpRequest.txt
Comment 3 Jaime Torres 2008-07-24 18:50:43 UTC
Confirmed using konqueror svn trunk 831729
Comment 4 Allan Sandfeld 2010-04-16 18:56:49 UTC
Are you sure the query is send twice?

KIO has a feature where it loads the first few bytes of a request to detect the mime-type using MAGIC, and then it issues a new request to load the rest. I am not sure if this is done for POST, but it is done for GET and could be what you are seeing.
Comment 5 Myriam Schweingruber 2012-06-18 18:31:33 UTC
Message from the Bugsquad and Konqueror teams:
This bug is closed as outdated, as we do not have the manpower to maintain the KDE3 version anymore.
If you still can reproduce this issue with Konqueror 4.8.4 or later, please open a new report.
Thank you for your understanding.