本文整理汇总了C++中HttpParser::setObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpParser::setObjectName方法的具体用法?C++ HttpParser::setObjectName怎么用?C++ HttpParser::setObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpParser
的用法示例。
在下文中一共展示了HttpParser::setObjectName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openNewSocket
/**
* ブラウザとの間に新しいソケットを開く
*/
void YASWebProxy::openNewSocket()
{
QTcpSocket* socket = server->nextPendingConnection();
connect(socket, SIGNAL(readyRead()), this, SLOT(openTunnel()));
connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
HttpParser* parser = new HttpParser(HttpParser::REQUEST, socket);
parser->setObjectName("requestParser");
connect(parser, SIGNAL(completeMessage(QByteArray)), this, SLOT(onRequest(QByteArray)));
}
示例2: openTunnel
/**
* ブラウザとのソケットと本来のホストとのソケットを接続するトンネルを作成
*/
void YASWebProxy::openTunnel()
{
QTcpSocket* socket = qobject_cast<QTcpSocket*>(sender());
QByteArray data = socket->readAll();
HttpParser* parser = socket->findChild<HttpParser*>("requestParser");
parser->input(data);
QTcpSocket* proxySocket = socket->findChild<QTcpSocket*>("tunnel");
if (!proxySocket) {
// 本来のホストへのソケットを作成
proxySocket = new QTcpSocket(socket);
proxySocket->setObjectName("tunnel");
proxySocket->connectToHost(parser->url.host(), parser->url.port(80));
connect(proxySocket, SIGNAL(disconnected()), this, SLOT(closeProxySocket()));
connect(proxySocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(closeProxySocket()));
connect(proxySocket, SIGNAL(readyRead()), this, SLOT(forwardResponse()));
if (parser->method == "CONNECT") {
disconnect(socket, SIGNAL(readyRead()), this, SLOT(openTunnel()));
connect(socket, SIGNAL(readyRead()), this, SLOT(forwardRequest()));
} else {
HttpParser* resParser = new HttpParser(HttpParser::RESPONSE, proxySocket);
resParser->setObjectName("responseParser");
resParser->setProperty("url", parser->url.toString());
connect(resParser, SIGNAL(completeMessage(QByteArray)), this, SLOT(onResponse(QByteArray)));
}
}
if (proxySocket->waitForConnected()) {
if (parser->method == "CONNECT") {
socket->write("HTTP/1.0 200 Connection established\r\n\r\n");
} else {
proxySocket->write(parser->dequeueData());
}
} else {
proxySocket->disconnect();
}
}