[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] QNetworkAccessManager and HTTP persistent connection
From:       "=?ISO-8859-1?B?aU1hdGg=?=" <2281570025 () qq ! com>
Date:       2013-11-23 13:36:38
Message-ID: tencent_209B64445EEF0B982E5A73C1 () qq ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]

[Attachment #4 (text/plain)]

HTTP 1.1 supports persistent connection by default, so I want to send my a second \
http request using the same connection that was setup when the first HTTP request was \
made. how can this be achieved through Qt?

If I simply make the second request after the first one finished like the following
manager = QNetworkAccessManager(self) \
manager.finished[QNetworkReply].connect(self.replyFinished) \
manager.get(QNetworkRequest(QUrl("http://qt.nokia.com")))  it seems a new TCP \
connection to the server will be initiated (I have checked with a network sniffer) \
The experiment also says: If the reply is deleteLater() or abort() within finished() \
signal, the connection will be closed.


[Attachment #5 (text/html)]

<p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; \
clear: both; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; \
line-height: 18px;">HTTP 1.1 supports persistent connection by default, so I want to \
send my a second http request using the same connection that was setup when the first \
HTTP request was made. how can this be achieved through Qt?</p><p style="margin: 0px \
0px 1em; padding: 0px; border: 0px; vertical-align: baseline; clear: both; \
font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: \
18px;">If I simply make the second request after the first one finished like the \
following</p><pre class="default prettyprint prettyprinted" style="margin-top: 0px; \
margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; \
background-color: rgb(238, 238, 238); font-family: Consolas, Menlo, Monaco, 'Lucida \
Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier \
New', monospace, serif; overflow: auto; width: auto; max-height: 600px; word-wrap: \
normal; line-height: 18px;"><pre><span class="n">manager</span> <span \
class="o">=</span> <span class="n"><font style="BACKGROUND-COLOR: #446ef8" \
color="#ffffff">QNetworkAccessManager</font></span><span class="p">(</span><span \
class="bp">self</span><span class="p">)</span> <span class="n">manager</span><span \
class="o">.</span><span class="n">finished</span><span class="p">[</span><span \
class="n">QNetworkReply</span><span class="p">]</span><span class="o">.</span><span \
class="n">connect</span><span class="p">(</span><span class="bp">self</span><span \
class="o">.</span><span class="n">replyFinished</span><span class="p">)</span>

<span class="n">manager</span><span class="o">.</span><span class="n">get</span><span \
class="p">(</span><span class="n">QNetworkRequest</span><span class="p">(</span><span \
class="n">QUrl</span><span class="p">(</span><span \
class="s">"http://qt.nokia.com"</span><span class="p">)))</span> </pre></pre><p \
style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; \
clear: both; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; \
line-height: 18px;">it seems a new TCP connection to the server will be initiated (I \
have checked with a network sniffer) The experiment also says: If the reply is \
deleteLater() or abort() within finished() signal, the connection will be closed.</p>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic