void createWindowForRequest(const FrameLoadRequest& request, Frame* openerFrame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer) { if (openerFrame->document()->pageDismissalEventBeingDispatched() != Document::NoDismissal) return; if (openerFrame->document() && openerFrame->document()->isSandboxed(SandboxPopups)) return; if (!DOMWindow::allowPopUp(openerFrame)) return; if (policy == NavigationPolicyCurrentTab) policy = NavigationPolicyNewForegroundTab; WindowFeatures features; bool created; Frame* newFrame = createWindow(openerFrame, openerFrame, request, features, policy, shouldSendReferrer, created); if (!newFrame) return; newFrame->page()->setOpenedByDOM(); if (shouldSendReferrer == MaybeSendReferrer) { newFrame->loader().setOpener(openerFrame); newFrame->document()->setReferrerPolicy(openerFrame->document()->referrerPolicy()); } FrameLoadRequest newRequest(0, request.resourceRequest()); newRequest.setFormState(request.formState()); newFrame->loader().load(newRequest); }
RequestID RequestManager::changeVSync(bool vsync) { RequestID rID = newRequest(kITCEventChangeVSync); (*rID)->_vsync.vsync = vsync; return rID; }
RequestID RequestManager::rebuild(Graphics::GLContainer &glContainer) { RequestID rID = newRequest(kITCEventRebuildGLContainer); (*rID)->_glContainer.glContainer = &glContainer; return rID; }
bool RenderFlowThread::hitTestRegion(RenderRegion* region, const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset) { LayoutRect regionRect(region->regionRect()); LayoutRect regionOverflowRect = region->regionOverflowRect(); LayoutRect regionClippingRect(accumulatedOffset + (regionOverflowRect.location() - regionRect.location()), regionOverflowRect.size()); if (!regionClippingRect.contains(pointInContainer)) return false; LayoutPoint renderFlowThreadOffset; if (style()->isFlippedBlocksWritingMode()) { LayoutRect flippedRegionRect(regionRect); flipForWritingMode(flippedRegionRect); renderFlowThreadOffset = LayoutPoint(accumulatedOffset - flippedRegionRect.location()); } else renderFlowThreadOffset = LayoutPoint(accumulatedOffset - regionRect.location()); LayoutPoint transformedPoint(pointInContainer.x() - renderFlowThreadOffset.x(), pointInContainer.y() - renderFlowThreadOffset.y()); // Always ignore clipping, since the RenderFlowThread has nothing to do with the bounds of the FrameView. HitTestRequest newRequest(request.type() | HitTestRequest::IgnoreClipping); RenderRegion* oldRegion = result.region(); result.setRegion(region); LayoutPoint oldPoint = result.point(); result.setPoint(transformedPoint); bool isPointInsideFlowThread = layer()->hitTest(newRequest, result); result.setPoint(oldPoint); result.setRegion(oldRegion); // FIXME: Should we set result.m_localPoint back to the RenderRegion's coordinate space or leave it in the RenderFlowThread's coordinate // space? Right now it's staying in the RenderFlowThread's coordinate space, which may end up being ok. We will know more when we get around to // patching positionForPoint. return isPointInsideFlowThread; }
RequestID RequestManager::changeFSAA(int level) { RequestID rID = newRequest(kITCEventChangeFSAA); (*rID)->_fsaa.level = level; return rID; }
// nova conexão foi estabelecida: void TcpServer::incomingConnection ( int socketDescriptor ) { // Quando um novo cliente é conectado, este server('QTcpServer') constrói um objeto 'QTcpSocket' // e toda a comunicação com esse cliente é feita através desse objeto 'QTcpSocket'. // 'QTcpSocket' trabalha assincronamente, ou seja, toda a comunicação é feita // nos slots 'readClient' (novos dados recebidos do cliente) // e 'discardClient' (o cliente desconectou). DataExchangeSocket* dataExchangeSocket = new DataExchangeSocket(this); // conecta os signals de 'DataExchangeSocket' aos slots desta classe: // Signal da base(QTcpSocket), slot da derivada(DataExchangeSocket) // Novos dados chegaram, prontos para leitura // (neste exemplo, é uma nova requisição de um cliente conectado): connect(dataExchangeSocket, SIGNAL(readyRead()), dataExchangeSocket, SLOT(newRequest())); // Signal da base(QTcpSocket), slot da base(QTcpSocket) // Ao desconectar, agenda o 'delete' desse objeto para o 'event-loop': connect(dataExchangeSocket, SIGNAL(disconnected()), dataExchangeSocket, SLOT(deleteLater())); // Define para o objeto 'dataExchangeSocket' o 'socket' recebido como argumento nesta função. // O 'socket'(um inteiro) identifica o endereço do cliente e a porta para intercâmbio de dados: dataExchangeSocket->setSocketDescriptor(socketDescriptor); }
void ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewRequest, const WebURLResponse& passedRedirectResponse) { ASSERT(m_state != Terminated); ResourceRequest& newRequest(applyOptions(passedNewRequest.toMutableResourceRequest())); ASSERT(!newRequest.isNull()); const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceResponse()); ASSERT(!redirectResponse.isNull()); newRequest.setFollowedRedirect(true); if (!isManualRedirectFetchRequest(m_resource->resourceRequest()) && !m_fetcher->canAccessRedirect(m_resource, newRequest, redirectResponse, m_options)) { cancel(ResourceError::cancelledDueToAccessCheckError(newRequest.url())); return; } ASSERT(m_state != Terminated); applyOptions(newRequest); // canAccessRedirect() can modify m_options so we should re-apply it. m_fetcher->redirectReceived(m_resource, redirectResponse); ASSERT(m_state != Terminated); m_resource->willFollowRedirect(newRequest, redirectResponse); if (newRequest.isNull() || m_state == Terminated) return; m_fetcher->willSendRequest(m_resource->identifier(), newRequest, redirectResponse, m_options.initiatorInfo); ASSERT(m_state != Terminated); ASSERT(!newRequest.isNull()); m_resource->updateRequest(newRequest); m_request = newRequest; }
void BeaconLoader::willSendRequest(WebURLLoader*, WebURLRequest& passedNewRequest, const WebURLResponse& passedRedirectResponse) { passedNewRequest.setAllowStoredCredentials(true); ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceResponse()); ASSERT(!newRequest.isNull()); ASSERT(!redirectResponse.isNull()); String errorDescription; StoredCredentials withCredentials = AllowStoredCredentials; ResourceLoaderOptions options; if (!CrossOriginAccessControl::handleRedirect(m_beaconOrigin.get(), newRequest, redirectResponse, withCredentials, options, errorDescription)) { if (page() && page()->mainFrame()) { if (page()->mainFrame()->isLocalFrame()) { LocalFrame* localFrame = toLocalFrame(page()->mainFrame()); if (localFrame->document()) localFrame->document()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, errorDescription)); } } // Cancel the load and self destruct. dispose(); return; } // FIXME: http://crbug.com/427429 is needed to correctly propagate // updates of Origin: following this successful redirect. }
void RequestManager::callInMainThread(const MainThreadCallerFunctor &caller) { RequestID rID = newRequest(kITCEventCallInMainThread); (*rID)->_callInMainThread.caller = &caller; dispatchAndWait(rID); }
bool RenderFlowThread::hitTestFlowThreadPortionInRegion(RenderRegion* region, LayoutRect flowThreadPortionRect, LayoutRect flowThreadPortionOverflowRect, const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset) const { LayoutRect regionClippingRect = computeRegionClippingRect(accumulatedOffset, flowThreadPortionRect, flowThreadPortionOverflowRect); if (!regionClippingRect.contains(locationInContainer.point())) return false; LayoutSize renderFlowThreadOffset; if (style()->isFlippedBlocksWritingMode()) { LayoutRect flippedFlowThreadPortionRect(flowThreadPortionRect); flipForWritingMode(flippedFlowThreadPortionRect); renderFlowThreadOffset = accumulatedOffset - flippedFlowThreadPortionRect.location(); } else renderFlowThreadOffset = accumulatedOffset - flowThreadPortionRect.location(); // Always ignore clipping, since the RenderFlowThread has nothing to do with the bounds of the FrameView. HitTestRequest newRequest(request.type() | HitTestRequest::IgnoreClipping); // Make a new temporary HitTestLocation in the new region. HitTestLocation newHitTestLocation(locationInContainer, -renderFlowThreadOffset, region); bool isPointInsideFlowThread = layer()->hitTest(newRequest, newHitTestLocation, result); // FIXME: Should we set result.m_localPoint back to the RenderRegion's coordinate space or leave it in the RenderFlowThread's coordinate // space? Right now it's staying in the RenderFlowThread's coordinate space, which may end up being ok. We will know more when we get around to // patching positionForPoint. return isPointInsideFlowThread; }
void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerFrame, NavigationPolicy policy) { ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document() && openerFrame.document()->url().isEmpty())); if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document::NoDismissal) return; if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPopups)) return; if (!LocalDOMWindow::allowPopUp(openerFrame)) return; if (policy == NavigationPolicyCurrentTab) policy = NavigationPolicyNewForegroundTab; WindowFeatures features; features.noopener = request.getShouldSetOpener() == NeverSetOpener; bool created; Frame* newFrame = createWindowHelper(openerFrame, openerFrame, openerFrame, request, features, policy, created); if (!newFrame) return; if (request.getShouldSendReferrer() == MaybeSendReferrer) { // TODO(japhet): Does ReferrerPolicy need to be proagated for RemoteFrames? if (newFrame->isLocalFrame()) toLocalFrame(newFrame)->document()->setReferrerPolicy(openerFrame.document()->getReferrerPolicy()); } // TODO(japhet): Form submissions on RemoteFrames don't work yet. FrameLoadRequest newRequest(0, request.resourceRequest()); newRequest.setForm(request.form()); if (newFrame->isLocalFrame()) toLocalFrame(newFrame)->loader().load(newRequest); }
RequestID RequestManager::destroy(Graphics::GLContainer &glContainer) { RequestID rID = newRequest(kITCEventDestroyGLContainer); (*rID)->_glContainer.glContainer = &glContainer; return rID; }
RequestID RequestManager::resize(int width, int height) { RequestID rID = newRequest(kITCEventResize); (*rID)->_resize.width = width; (*rID)->_resize.height = height; return rID; }
TinySqlApiStorage::TinySqlApiStorage(QObject *parent, TinySqlApiServer &server) : QObject(parent), mServer(server) { mSqlHandler = new TinySqlApiSql(this); Q_CHECK_PTR(mSqlHandler); connect(&mServer, SIGNAL(newRequest()), this, SLOT(handleRequest())); }
QString BusReader::getBus(const QString &msg) { //QString str = "Hello"; QNetworkRequest newRequest("http://www.tmb.cat/piu/ca_ES/piuimodesolucio.jsp?parada="+msg); networkManager.get(newRequest); connect(&networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(handleNetworkData(QNetworkReply*))); return msg; }
TinySqlApiStorage::~TinySqlApiStorage() { DPRINT << "SQLITEAPISRV:~TinySqlApiStorage.."; disconnect(&mServer, SIGNAL(newRequest()), this, SLOT(handleRequest())); delete mSqlHandler; mSqlHandler = NULL; }
void ClientInfo::newPeerRequest( const HostAndPort& peer ) { if ( ! _remote.hasPort() ) _remote = peer; else if ( _remote != peer ) { stringstream ss; ss << "remotes don't match old [" << _remote.toString() << "] new [" << peer.toString() << "]"; throw UserException( 13134 , ss.str() ); } newRequest(); }
void ConnectionManager::read() { QRegExp rex("[|]"); QString s(m_sock->readAll()); QStringList list = s.split(rex, QString::SkipEmptyParts); for(QString req : list) { qDebug() << "Request received : " << req; m_requests.insert(m_requests.begin(), new Request(req.toStdString())); } emit newRequest(this); }
void DocumentThreadableLoader::loadRequestAsync( const ResourceRequest& request, ResourceLoaderOptions resourceLoaderOptions) { if (!m_actualRequest.isNull()) resourceLoaderOptions.dataBufferingPolicy = BufferData; if (m_options.timeoutMilliseconds > 0) { m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE); } FetchRequest newRequest(request, m_options.initiator, resourceLoaderOptions); if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); DCHECK(!resource()); if (request.requestContext() == WebURLRequest::RequestContextVideo || request.requestContext() == WebURLRequest::RequestContextAudio) setResource(RawResource::fetchMedia(newRequest, document().fetcher())); else if (request.requestContext() == WebURLRequest::RequestContextManifest) setResource(RawResource::fetchManifest(newRequest, document().fetcher())); else setResource(RawResource::fetch(newRequest, document().fetcher())); if (!resource()) { InspectorInstrumentation:: documentThreadableLoaderFailedToStartLoadingForClient(m_document, m_client); ThreadableLoaderClient* client = m_client; clear(); // setResource() might call notifyFinished() and thus clear() // synchronously, and in such cases ThreadableLoaderClient is already // notified and |client| is null. if (!client) return; client->didFail(ResourceError(errorDomainBlinkInternal, 0, request.url().getString(), "Failed to start loading.")); return; } if (resource()->isLoading()) { unsigned long identifier = resource()->identifier(); InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient( m_document, identifier, m_client); } else { InspectorInstrumentation:: documentThreadableLoaderFailedToStartLoadingForClient(m_document, m_client); } }
void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebURLLoaderClient* client) { ASSERT(!m_loader); ASSERT(!m_client); m_client = client; ASSERT(m_client); bool allowLoad = true; WebURLRequest newRequest(request); if (m_options.untrustedHTTP) { WebString method = newRequest.httpMethod(); allowLoad = isValidHTTPToken(method) && FetchUtils::isUsefulMethod(method); if (allowLoad) { newRequest.setHTTPMethod(FetchUtils::normalizeMethod(method)); HTTPRequestHeaderValidator validator; newRequest.visitHTTPHeaderFields(&validator); allowLoad = validator.isSafe(); } } m_clientAdapter = ClientAdapter::create(this, m_client, m_options); if (allowLoad) { ThreadableLoaderOptions options; options.preflightPolicy = static_cast<PreflightPolicy>(m_options.preflightPolicy); options.crossOriginRequestPolicy = static_cast<CrossOriginRequestPolicy>(m_options.crossOriginRequestPolicy); ResourceLoaderOptions resourceLoaderOptions; resourceLoaderOptions.allowCredentials = m_options.allowCredentials ? AllowStoredCredentials : DoNotAllowStoredCredentials; resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; const ResourceRequest& webcoreRequest = newRequest.toResourceRequest(); if (webcoreRequest.requestContext() == WebURLRequest::RequestContextUnspecified) { // FIXME: We load URLs without setting a TargetType (and therefore a request context) in several // places in content/ (P2PPortAllocatorSession::AllocateLegacyRelaySession, for example). Remove // this once those places are patched up. newRequest.setRequestContext(WebURLRequest::RequestContextInternal); } Document* webcoreDocument = m_frameImpl->frame()->document(); ASSERT(webcoreDocument); m_loader = DocumentThreadableLoader::create(*webcoreDocument, m_clientAdapter.get(), webcoreRequest, options, resourceLoaderOptions); } if (!m_loader) { // FIXME: return meaningful error codes. m_clientAdapter->setDelayedError(ResourceError()); } m_clientAdapter->enableErrorNotifications(); }
bool AuthManager::go(const QString& login, const QString& pass, const QString& captcha) { narodLogin = login; narodPass = pass; QString narodCaptchaKey = captcha; Options *o = Options::instance(); QByteArray post = "login="******"&passwd=" + narodPass.toLatin1(); if (narodLogin.isEmpty() || narodPass.isEmpty() || !narodCaptchaKey.isEmpty()) { requestAuthDialog authdialog; authdialog.setLogin(narodLogin); authdialog.setPasswd(narodPass); if (!narodCaptchaKey.isEmpty()) { authdialog.setCaptcha(manager_->cookieJar()->cookiesForUrl(mainUrl), "http://passport.yandex.ru/digits?idkey=" + narodCaptchaKey); } if (authdialog.exec()) { narodLogin = authdialog.getLogin(); narodPass = authdialog.getPasswd(); if (authdialog.getRemember()) { o->setOption(CONST_LOGIN, narodLogin); o->setOption(CONST_PASS, Options::encodePassword(narodPass)); } post = "login="******"&passwd=" + narodPass.toLatin1(); } else { post.clear(); } if (!post.isEmpty() && !narodCaptchaKey.isEmpty()) { post += "&idkey="+narodCaptchaKey.toLatin1()+"&code="+authdialog.getCode(); } } if (!post.isEmpty()) { post += "&twoweeks=yes"; QNetworkRequest nr = newRequest(); nr.setUrl(authUrl); nr.setHeader(QNetworkRequest::ContentLengthHeader, post.length()); nr.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); manager_->post(nr, post); if(!loop_->isRunning()) { timer_->start(); loop_->exec(); } } else { return false; } return authorized_; }
void AuthManager::replyFinished(QNetworkReply* reply) { QVariant cooks = reply->header(QNetworkRequest::SetCookieHeader); if (!cooks.isNull()) { bool found = false; foreach (const QNetworkCookie& netcook, qVariantValue< QList<QNetworkCookie> >(cooks)) { if (netcook.name() == "yandex_login" && !netcook.value().isEmpty()) { found = true; break; } } if (!found) { QRegExp rx("<input type=\"?submit\"?[^>]+name=\"no\""); QString page = reply->readAll(); if (rx.indexIn(page) > 0) { QRegExp rx1("<input type=\"hidden\" name=\"idkey\" value=\"(\\S+)\"[^>]*>"); if (rx1.indexIn(page) > 0) { QByteArray post = "idkey=" + rx1.cap(1).toAscii() + "&filled=yes"; QNetworkRequest nr = newRequest(); nr.setUrl(authUrl); nr.setHeader(QNetworkRequest::ContentLengthHeader, post.length()); nr.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); manager_->post(nr, post); reply->deleteLater(); return; } } else { rx.setPattern("<input type=\"hidden\" name=\"idkey\" value=\"(\\S+)\" />"); if (rx.indexIn(page) > 0) { timer_->stop(); go(narodLogin, narodPass, rx.cap(1)); reply->deleteLater(); return; } else { authorized_ = false; loop_->exit(); reply->deleteLater(); return; } } } else { authorized_ = true; loop_->exit(); reply->deleteLater(); return; } }
struct Request const parseRequest(const char * const aInput) { struct Request result = newRequest(); regex_t regex; regmatch_t matches[GROUP_COUNT]; if ( regcomp( ®ex, MASK, REG_EXTENDED ) ) { printf("\nCould not compile regular expression."); result.invalid = 1; return result; }; if ( regexec( ®ex, aInput, GROUP_COUNT, matches, 0 ) == 0 ) { // command int length = matches[1].rm_eo - matches[1].rm_so; result.command = malloc( length + 1 ); strncpy( result.command, aInput, length ); result.command[ length ] = '\0'; // path length = matches[2].rm_eo - matches[2].rm_so; result.path = malloc( length + 1 ); strncpy( result.path, aInput + matches[2].rm_so, length); result.path[ length ] = '\0'; // http version length = matches[3].rm_eo - matches[3].rm_so; result.httpVersion = malloc( length + 1 ); strncpy( result.httpVersion, aInput + matches[3].rm_so, length); result.httpVersion[ length ] = '\0'; // headers length = matches[4].rm_eo - matches[4].rm_so; result.headers = malloc( length + 1 ); strncpy( result.headers, aInput + matches[4].rm_so, length); result.headers[ length ] = '\0'; } else { result.invalid = 1; return result; } regfree(®ex); return result; }
bool ResourceLoader::willFollowRedirect( WebURLRequest& passedNewRequest, const WebURLResponse& passedRedirectResponse) { DCHECK(!passedNewRequest.isNull()); DCHECK(!passedRedirectResponse.isNull()); if (m_isCacheAwareLoadingActivated) { // Fail as cache miss if cached response is a redirect. didFail( ResourceError::cacheMissError(m_resource->lastResourceRequest().url())); return false; } ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); const ResourceResponse& redirectResponse( passedRedirectResponse.toResourceResponse()); newRequest.setRedirectStatus( ResourceRequest::RedirectStatus::FollowedRedirect); const KURL originalURL = newRequest.url(); ResourceRequestBlockedReason blockedReason = m_fetcher->willFollowRedirect( m_resource.get(), newRequest, redirectResponse); if (blockedReason != ResourceRequestBlockedReason::None) { cancelForRedirectAccessCheckError(newRequest.url(), blockedReason); return false; } // ResourceFetcher::willFollowRedirect() may rewrite the URL to // something else not for rejecting redirect but for other reasons. // E.g. WebFrameTestClient::willSendRequest() and // RenderFrameImpl::willSendRequest(). We should reflect the // rewriting but currently we cannot. So, return false to make the // redirect fail. if (newRequest.url() != originalURL) { cancelForRedirectAccessCheckError(newRequest.url(), ResourceRequestBlockedReason::Other); return false; } if (!m_resource->willFollowRedirect(newRequest, redirectResponse)) { cancelForRedirectAccessCheckError(newRequest.url(), ResourceRequestBlockedReason::Other); return false; } return true; }
QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart) { // copy the request, we probably need to add some headers QNetworkRequest newRequest(request); // add Content-Type header if not there already if (!request.header(QNetworkRequest::ContentTypeHeader).isValid()) { QByteArray contentType; contentType.reserve(34 + multiPart->d_func()->boundary.count()); contentType += "multipart/"; switch (multiPart->d_func()->contentType) { case QHttpMultiPart::RelatedType: contentType += "related"; break; case QHttpMultiPart::FormDataType: contentType += "form-data"; break; case QHttpMultiPart::AlternativeType: contentType += "alternative"; break; default: contentType += "mixed"; break; } // putting the boundary into quotes, recommended in RFC 2046 section 5.1.1 contentType += "; boundary=\"" + multiPart->d_func()->boundary + "\""; newRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(contentType)); } // add MIME-Version header if not there already (we must include the header // if the message conforms to RFC 2045, see section 4 of that RFC) QByteArray mimeHeader("MIME-Version"); if (!request.hasRawHeader(mimeHeader)) newRequest.setRawHeader(mimeHeader, QByteArray("1.0")); QIODevice *device = multiPart->d_func()->device; if (!device->isReadable()) { if (!device->isOpen()) { if (!device->open(QIODevice::ReadOnly)) qWarning("could not open device for reading"); } else { qWarning("device is not readable"); } } return newRequest; }
void MainWindows::tryLoinTriggered() { QNetworkRequest newRequest(QUrl(BOX_LOGIN_URL_TTPS)); QEventLoop eventLoop; QString replyText; QNetworkReply * reply = nullptr; QString postData = QString(BOX_LOGIN_POST_DATA) .arg(this->_autToken.toHtmlEscaped()) .arg(QString("*****@*****.**").toHtmlEscaped()) .arg(QString("*********")); newRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); newRequest.setRawHeader("origin", "https://box.es"); newRequest.setSslConfiguration(*this->_sslConfig); reply = this->_networkManager->post(newRequest, QByteArray(postData.toStdString().c_str())); QObject::connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit); eventLoop.exec(); if (reply->error() != QNetworkReply::NoError) { qDebug() << "Network Error:" << reply->errorString(); return; } replyText = reply->readAll(); const QList<QPair<QByteArray, QByteArray>> headers = reply->rawHeaderPairs(); for each (auto pair in headers) { qDebug() << "header name:" << pair.first << "header data" << pair.second; } if (replyText.isNull() || replyText.isEmpty()) { qDebug() << "Answer for" << BOX_BASE_URL_HTTPS << "was empty or null"; this->_ui.statusBar->setStatusTip(QString("Answer for ").append(BOX_BASE_URL_HTTPS).append(" was empty or null")); return; } }
PassRefPtr<DocumentLoader> FrameLoaderClientBlackBerry::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) { // Make a copy of the request with the token from the original request for this frame // (unless it already has a token, in which case the request came from the client). ResourceRequest newRequest(request); if (m_frame && m_frame->loader() && m_frame->loader()->documentLoader()) { const ResourceRequest& originalRequest = m_frame->loader()->documentLoader()->originalRequest(); if (request.token().isNull() && !originalRequest.token().isNull()) newRequest.setToken(originalRequest.token()); } // FIXME: This should probably be shared. RefPtr<DocumentLoader> loader = DocumentLoader::create(newRequest, substituteData); if (substituteData.isValid()) loader->setDeferMainResourceDataLoad(false); return loader.release(); }
DbResponse ClusterCommandTestFixture::runCommand(BSONObj cmd) { // Create a new client/operation context per command auto client = getServiceContext()->makeClient("ClusterCmdClient"); auto opCtx = client->makeOperationContext(); const auto opMsgRequest = OpMsgRequest::fromDBAndBody(kNss.db(), cmd); // Ensure the clusterGLE on the Client has not yet been initialized. ASSERT(!ClusterLastErrorInfo::get(client.get())); // Initialize the cluster last error info for the client with a new request. ClusterLastErrorInfo::get(client.get()) = std::make_shared<ClusterLastErrorInfo>(); ASSERT(ClusterLastErrorInfo::get(client.get())); auto clusterGLE = ClusterLastErrorInfo::get(client.get()); clusterGLE->newRequest(); return Strategy::clientCommand(opCtx.get(), opMsgRequest.serialize()); }
QNetworkReply* AccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData) { QNetworkRequest newRequest(request); if (newRequest.hasRawHeader("cookie")) { // This will set the cookie into the QNetworkCookieJar which will then override the cookie header setRawCookie(request.rawHeader("cookie"), request.url()); } newRequest.setRawHeader(QByteArray("User-Agent"), Utility::userAgentString()); QByteArray verb = newRequest.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray(); // For PROPFIND (assumed to be a WebDAV op), set xml/utf8 as content type/encoding // This needs extension if (verb == "PROPFIND") { newRequest.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml; charset=utf-8")); } return QNetworkAccessManager::createRequest(op, newRequest, outgoingData); }
QNetworkReply * Ororok::lastfm::NetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData) { QNetworkRequest newRequest(req); QUrl url = req.url(); // force url scheme to https, another workaround if (url.host() == "ws.audioscrobbler.com") { url.setScheme("https"); url.setPort(-1); } newRequest.setUrl(url); return QNetworkAccessManager::createRequest(op, newRequest, outgoingData); }