KDECore
Go to the documentation of this file.
28 #include <config-network.h>
30 #include <sys/types.h>
31 #include <sys/socket.h>
33 #include <QSocketNotifier>
40 using namespace KNetwork;
44 class KNetwork::KHttpProxySocketDevicePrivate
52 KHttpProxySocketDevicePrivate()
63 : d(new KHttpProxySocketDevicePrivate)
94 d->reply = d->request = QByteArray();
113 if (d->proxy.family() == AF_UNSPEC)
130 return parseServerReply();
136 if (
m_sockfd == -1 && (d->proxy.family() == AF_UNSPEC ||
137 node.isEmpty() || service.isEmpty()))
155 KActiveSocketBase::close();
158 QString request = QLatin1String(
"CONNECT %1:%2 HTTP/1.1\r\n"
159 "Cache-Control: no-cache\r\n"
163 if (node.contains(QLatin1Char(
':')))
164 node2 = QLatin1Char(
'[') + node + QLatin1Char(
']');
166 d->request = request.arg(node2).arg(service).toLatin1();
169 return parseServerReply();
172 bool KHttpProxySocketDevice::parseServerReply()
181 if (!d->request.isEmpty())
187 qDebug(
"KHttpProxySocketDevice: would block writing request!");
192 qDebug(
"KHttpProxySocketDevice: request written");
194 d->request.remove(0, written);
196 if (!d->request.isEmpty())
211 qDebug(
"KHttpProxySocketDevice: %lld bytes available", avail);
212 KActiveSocketBase::close();
223 if (
peekData(buf.data(), avail) < 0)
226 QByteArray fullHeaders = d->reply + buf;
228 index = fullHeaders.indexOf(
"\r\n\r\n");
234 d->reply += buf.data();
240 index -= d->reply.length();
241 d->reply += fullHeaders.mid(d->reply.length(), index + 4);
249 if (d->reply.endsWith(
"\r\n\r"))
251 else if (d->reply.endsWith(
"\r\n"))
253 else if (d->reply.endsWith(
'\r'))
261 if ((state == 3 && c ==
'\n') ||
262 (state == 1 && c ==
'\n') ||
271 qDebug(
"KHttpProxySocketDevice: get reply: %s\n",
272 d->reply.left(d->reply.indexOf(
'\r')).data());
273 if (d->reply.left(7) !=
"HTTP/1." ||
274 (index = d->reply.indexOf(
' ')) == -1 ||
275 d->reply[index + 1] !=
'2')
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jun 1 2013 21:52:33 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.