Bug 283794 - konqueror sends invalid proxy requests when configured for use with proxies (since 4.7.2)
Summary: konqueror sends invalid proxy requests when configured for use with proxies (...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Dawit Alemayehu
URL:
Keywords:
: 284427 284999 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-11 14:57 UTC by Andreas Erhart
Modified: 2011-10-26 12:06 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.7.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Erhart 2011-10-11 14:57:40 UTC
Version:           Git (using Devel) 
OS:                Linux

After upgrading to 4.7.2 on my gentoo box my configured squid proxy complains about invalid requests from all khtml based browsers.
Here is an example of the raw request as recorded at the proxy:

GET /search?q=kde+4.7.2+squid&ie=UTF-8&oe=UTF-8 HTTP/1.1
Host: www.google.de
Connection: keep-alive
User-Agent: Mozilla/5.0 (X11) KHTML/4.7.2 (like Gecko) Konqueror/4.7
Accept: text/html, text/*;q=0.9, image/jpeg;q=0.9, image/png;q=0.9, image/*;q=0.9, */*;q=0.8
Accept-Encoding: gzip, deflate, x-gzip, x-deflate
Accept-Charset: utf-8,*;q=0.5
Accept-Language: de,en-US;q=0.9,en;q=0.8

this looks like an relative URI in the request line while it should ask for a fully qualified URL.
I'm using a proxy configuration script but it doesn't matter how the proxy was configured.

Reproducible: Always

Steps to Reproduce:
Simply configure a proxy in the global settings and try to surf. If you are using squid as an proxy you get the error as described above.
I only tried it with gentoo because I don't have boxes running other dirstibutions.

Actual Results:  
malformed proxy request starting with:

GET /search?q=kde+4.7.2+squid&ie=UTF-8&oe=UTF-8 HTTP/1.1
Host: www.google.de
...

Expected Results:  
valid proxy request using fully qualified URL:

GET http://www.google.com/search?q=kde+4.7.2+squid&ie=UTF-8&oe=UTF-8 HTTP/1.1
...
Comment 1 Dawit Alemayehu 2011-10-13 20:23:23 UTC
Please enable debugging for the HTTP ioslave as specified in

http://techbase.kde.org/Development/Tutorials/Debugging/Debugging_IOSlaves#How_to_get_debug_output

and post them here so that we can see what is happening in kio_http. Please sanitize the debug file for cookies and other private information. I can tell you for sure that if you are connecting to HTTPS sites through a HTTP proxy server then the request header URL is supposed to be relative since we are directly connected to the remote server. IOW, the proxy server is supposed create a tunnel and let us connect directly to the secured site.
Comment 2 Andreas Erhart 2011-10-14 07:47:25 UTC
After some further investigations I found out that the problem only occures if I use a proxy configuration file (in my case a local proxy.pac file which I'm using for all my browsers). It works perfectly when I use manually configured proxy settings.
Additionally I have the enviroment variables $http_proxy, $https_proxy and $ftp_proxy set which might be responsible for sending the requests to our proxies even if http io_slave ignores my proxy.pac. (I will investigate that)

I also want to make clear that for me this incident is clearly a regression because it used to work flawlessly with the same configuration before I did the upgrade from 4.7.1 to 4.7.2.

Here is the debug output from "kdebugdialog --fullmode" for http:

kio_http(23476) HTTPProtocol::sendQuery: ============ Sending Header:
kio_http(23476) HTTPProtocol::sendQuery: "GET / HTTP/1.1"
kio_http(23476) HTTPProtocol::sendQuery: "Host: www.kde.org"
kio_http(23476) HTTPProtocol::sendQuery: "Connection: keep-alive"
kio_http(23476) HTTPProtocol::sendQuery: "User-Agent: Mozilla/5.0 (X11) KHTML/4.7.2 (like Gecko) Konqueror/4.7"
kio_http(23476) HTTPProtocol::sendQuery: "Accept: text/html, text/*;q=0.9, image/jpeg;q=0.9, image/png;q=0.9, image/*;q=0.9, */*;q=0.8"
kio_http(23476) HTTPProtocol::sendQuery: "Accept-Encoding: gzip, deflate, x-gzip, x-deflate"
kio_http(23476) HTTPProtocol::sendQuery: "Accept-Charset: utf-8,*;q=0.5"
kio_http(23476) HTTPProtocol::sendQuery: "Accept-Language: de,en-US;q=0.9,en;q=0.8"
kio_http(23476) HTTPProtocol::readResponseHeader: ============ Received Status Response:
kio_http(23476) HTTPProtocol::readResponseHeader: "HTTP/1.0 400 Bad Request"
kio_http(23478) HTTPProtocol::sendQuery: ============ Sending Header:
kio_http(23478) HTTPProtocol::sendQuery: "GET /favicon.ico HTTP/1.1"
kio_http(23478) HTTPProtocol::sendQuery: "Host: www.kde.org"
kio_http(23478) HTTPProtocol::sendQuery: "Connection: keep-alive"
kio_http(23478) HTTPProtocol::sendQuery: "User-Agent: Mozilla/5.0 (X11) KHTML/4.7.2 (like Gecko) Konqueror/4.7"
kio_http(23478) HTTPProtocol::sendQuery: "Pragma: no-cache"
kio_http(23478) HTTPProtocol::sendQuery: "Cache-control: no-cache"
kio_http(23478) HTTPProtocol::sendQuery: "Accept: text/html, text/*;q=0.9, image/jpeg;q=0.9, image/png;q=0.9, image/*;q=0.9, */*;q=0.8"
kio_http(23478) HTTPProtocol::sendQuery: "Accept-Encoding: gzip, deflate, x-gzip, x-deflate"
kio_http(23478) HTTPProtocol::sendQuery: "Accept-Charset: utf-8,*;q=0.5"
kio_http(23478) HTTPProtocol::sendQuery: "Accept-Language: de,en-US;q=0.9,en;q=0.8"
kio_http(23478) HTTPProtocol::readResponseHeader: ============ Received Status Response:
kio_http(23478) HTTPProtocol::readResponseHeader: "HTTP/1.0 400 Bad Request"


and here is my proxy.pac :

function FindProxyForURL(url, host) {
        if (localHostOrDomainIs(host, "localhost"))
                return "DIRECT";
        var noproxy = new Array("*enterprise.example.com*","*brz.example.com*");
        for (p in noproxy) {
                if (shExpMatch(url, noproxy[p]))
                        return "DIRECT";
        }
        return "PROXY proxy.example.com:8080;DIRECT";
}


Thanks for your support !

Best Regards

Andi
Comment 3 Andreas Erhart 2011-10-14 11:33:52 UTC
This issue is related only to proxy configuration file (proxy.pac). The proxy enviroment variables don't affect the behaviour in any ways
Comment 4 Dawit Alemayehu 2011-10-14 14:48:55 UTC
(In reply to comment #3)
> This issue is related only to proxy configuration file (proxy.pac). The proxy
> enviroment variables don't affect the behaviour in any ways

Right. Unless you setup Konqueror's proxy settings to use the system proxy settings, it won't use the environment variables you mentioned ; so that makes sense. 

The debug output you provided is only for debug area 7103 (kio_http). Please enable the other debug area 7113 (kio_http_debug) to get a more verbose output. It is most definitely incorrect for kio_http to send the GET header it is sending if it is using the proxy configuration in the PAC file you provided above.
Comment 5 Andreas Erhart 2011-10-18 09:56:33 UTC
I hope I have the right debugging information this time. This is the debug record of one http request against bugs.kde.org using a proxy.pac from local filesystem:

kio_http(18897)/kio_http_debug HTTPProtocol::reparseConfiguration:
kio_http(18897)/kio_http_debug HTTPProtocol::setHost: Hostname is now: "bugs.kde.org" ( "bugs.kde.org" )
kio_http(18897)/kio_http_debug HTTPProtocol::get: "http://bugs.kde.org"
kio_http(18897)/kio_http_debug HTTPProtocol::maybeSetRequestUrl: "http://bugs.kde.org"
kio_http(18897)/kio_http_debug HTTPProtocol::get: "http://bugs.kde.org/"
kio_http(18897)/kio_http_debug HTTPProtocol::maybeSetRequestUrl: "http://bugs.kde.org/"
kio_http(18897)/kio_http_debug HTTPProtocol::resetSessionSettings: Window Id = "117440946"
kio_http(18897)/kio_http_debug HTTPProtocol::resetSessionSettings: ssl_was_in_use = ""
kio_http(18897)/kio_http_debug HTTPProtocol::proceedUntilResponseContent:
kio_http(18897)/kio_http_debug HTTPProtocol::proceedUntilResponseHeader:
kio_http(18897)/kio_http_debug HTTPProtocol::sendQuery:
kio_http(18897)/kio_http_debug HTTPProtocol::httpShouldCloseConnection:
kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection:
kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection: Proxy URLs: ("https://pro-campus.example.com:8080", "DIRECT")
kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection: Connecting to proxy: address= "https://pro-campus.example.com:8080" type= 2
kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection: Connected to proxy: host= "pro-campus.example.com" port= 8080
kio_http(18897)/kio_http_debug HTTPProtocol::satisfyRequestFromCache:
kio_http(18897)/kio_http_debug HTTPProtocol::cacheFileOpenRead:
kio_http(18897)/kio_http_debug HTTPProtocol::cacheFileClose:
kio_http(18897)/kio_http_debug HTTPProtocol::sendQuery: sent it!
kio_http(18897)/kio_http_debug HTTPProtocol::readResponseHeader:
kio_http(18897)/kio_http_debug HTTPProtocol::readResponseHeader: wasAuthError= false isAuthError= false sameAuthError= false
kio_http(18897)/kio_http_debug HTTPProtocol::readResponseHeader:  -- full response:
"HTTP/1.0 400 Bad Request
Server: squid/2.7.STABLE6
Date: Tue, 18 Oct 2011 09:48:57 GMT
Content-Type: text/html
Content-Length: 1944
X-Squid-Error: ERR_INVALID_REQ 0
X-Cache: MISS from pro-c01.example.com
Via: 1.0 pro-c01.example.com:8080 (squid/2.7.STABLE6)
Connection: close"
kio_http(18897)/kio_http_debug HTTPProtocol::readResponseHeader: Content-type: "text/html"
kio_http(18897)/kio_http_debug HTTPProtocol::fixupResponseMimetype: before fixup "text/html"
kio_http(18897)/kio_http_debug HTTPProtocol::fixupResponseMimetype: after fixup "text/html"
kio_http(18897)/kio_http_debug HTTPProtocol::readResponseHeader: Emitting mimetype  "text/html"
kio_http(18897)/kio_http_debug HTTPProtocol::proceedUntilResponseHeader: Previous Response: 0
kio_http(18897)/kio_http_debug HTTPProtocol::proceedUntilResponseHeader: Current Response: 400
kio_http(18897)/kio_http_debug HTTPProtocol::readBody: "1944" bytes left.
kio_http(18897)/kio_http_debug HTTPProtocol::readBody: EOD received! Left = "0"
kio_http(18897)/kio_http_debug HTTPProtocol::cacheFileClose:
kio_http(18897)/kio_http_debug HTTPProtocol::httpClose: keepAlive = false
kio_http(18897)/kio_http_debug HTTPProtocol::cacheFileClose:
kio_http(18897)/kio_http_debug HTTPProtocol::httpCloseConnection:
kio_http(18897)/kio_http_debug HTTPProtocol::httpClose: keepAlive = false
kio_http(18897)/kio_http_debug HTTPProtocol::cacheFileClose:
kio_http(18897)/kio_http_debug HTTPProtocol::httpCloseConnection:
kio_http(18776)/kio_http_debug HTTPProtocol::setHost: Hostname is now: "bugs.kde.org" ( "bugs.kde.org" )
kio_http(18776)/kio_http_debug HTTPProtocol::get: "http://bugs.kde.org/favicon.ico"
kio_http(18776)/kio_http_debug HTTPProtocol::maybeSetRequestUrl: "http://bugs.kde.org/favicon.ico"
kio_http(18776)/kio_http_debug HTTPProtocol::resetSessionSettings: Window Id = ""
kio_http(18776)/kio_http_debug HTTPProtocol::resetSessionSettings: ssl_was_in_use = ""
kio_http(18776)/kio_http_debug HTTPProtocol::proceedUntilResponseContent:
kio_http(18776)/kio_http_debug HTTPProtocol::proceedUntilResponseHeader:
kio_http(18776)/kio_http_debug HTTPProtocol::sendQuery:
kio_http(18776)/kio_http_debug HTTPProtocol::httpShouldCloseConnection:
kio_http(18776)/kio_http_debug HTTPProtocol::httpOpenConnection:
kio_http(18776)/kio_http_debug HTTPProtocol::httpOpenConnection: Proxy URLs: ("https://pro-campus.example.com:8080", "DIRECT")
kio_http(18776)/kio_http_debug HTTPProtocol::httpOpenConnection: Connecting to proxy: address= "https://pro-campus.example.com:8080" type= 2
kio_http(18776)/kio_http_debug HTTPProtocol::httpOpenConnection: Connected to proxy: host= "pro-campus.example.com" port= 8080
kio_http(18776)/kio_http_debug HTTPProtocol::satisfyRequestFromCache:
kio_http(18776)/kio_http_debug HTTPProtocol::sendQuery: sent it!
kio_http(18776)/kio_http_debug HTTPProtocol::readResponseHeader:
kio_http(18776)/kio_http_debug HTTPProtocol::httpClose: keepAlive = false
kio_http(18776)/kio_http_debug HTTPProtocol::cacheFileClose:
kio_http(18776)/kio_http_debug HTTPProtocol::httpCloseConnection:
kio_http(18776)/kio_http_debug HTTPProtocol::cacheFileClose:
kio_http(18776)/kio_http_debug HTTPProtocol::httpClose: keepAlive = false
kio_http(18776)/kio_http_debug HTTPProtocol::cacheFileClose:
kio_http(18776)/kio_http_debug HTTPProtocol::httpCloseConnection:
Comment 6 Andreas Erhart 2011-10-18 10:02:30 UTC
I don't understand where kio_http found the following:

kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection: Proxy URLs: ("https://pro-campus.example.com:8080", "DIRECT")
kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection: Connecting to proxy: address= "https://pro-campus.example.com:8080" type= 2

I do not have any proxy configuration which enforces https as proxy protocol. Please compare with the proxy configuration script above.
Comment 7 Dawit Alemayehu 2011-10-18 14:52:12 UTC
(In reply to comment #6)
> I don't understand where kio_http found the following:
>
> kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection: Proxy URLs:
> ("https://pro-campus.example.com:8080", "DIRECT")
> kio_http(18897)/kio_http_debug HTTPProtocol::httpOpenConnection: Connecting to
> proxy: address= "https://pro-campus.example.com:8080" type= 2
> 
> I do not have any proxy configuration which enforces https as proxy protocol.
> Please compare with the proxy configuration script above.

Hmm... indeed. It must be a logic error in the proxyscout library that handles PAC files. Will look into it shortly.
Comment 8 Dawit Alemayehu 2011-10-18 14:55:19 UTC
Git commit 56a4c56a134fee7334cecb5ae8b27a37f8060e66 by Dawit Alemayehu.
Committed on 18/10/2011 at 12:53.
Pushed by adawit into branch 'KDE/4.7'.

Append http not https to the address specified through the
PROXY keyword.

BUG: 283794
FIXED-IN: 4.7.3

M  +1    -1    kio/misc/kpac/proxyscout.cpp

http://commits.kde.org/kdelibs/56a4c56a134fee7334cecb5ae8b27a37f8060e66
Comment 9 Dawit Alemayehu 2011-10-19 14:54:54 UTC
*** Bug 284427 has been marked as a duplicate of this bug. ***
Comment 10 Dawit Alemayehu 2011-10-25 15:14:17 UTC
*** Bug 284763 has been marked as a duplicate of this bug. ***
Comment 11 Manuel Siggen 2011-10-26 12:06:46 UTC
*** Bug 284999 has been marked as a duplicate of this bug. ***