QUrl lastfm::UrlBuilder::url() const { QUrl url; url.setScheme( "http" ); url.setHost( host() ); #if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) url.setPath( d->path ); #else url.setEncodedPath( d->path ); #endif return url; }
bool Pillow::HttpHandlerProxy::handleRequest(Pillow::HttpConnection *request) { if (_proxiedUrl.isEmpty()) return false; QUrl targetUrl = _proxiedUrl; targetUrl.setEncodedPath(request->requestPath()); if (!request->requestQueryString().isEmpty()) targetUrl.setEncodedQuery(request->requestQueryString()); if (!request->requestFragment().isEmpty()) targetUrl.setEncodedFragment(request->requestFragment()); QNetworkRequest proxiedRequest(targetUrl); foreach (const Pillow::HttpHeader& header, request->requestHeaders()) proxiedRequest.setRawHeader(header.first, header.second); createPipe(request, createProxiedReply(request, proxiedRequest)); return true; }
void QUrlProto::setEncodedPath(const QByteArray &path) { QUrl *item = qscriptvalue_cast<QUrl*>(thisObject()); if (item) item->setEncodedPath(path); }
void GwtCallback::browseUrl(QString url) { QUrl qurl(url); #ifdef Q_WS_MAC if (qurl.scheme() == QString::fromAscii("file")) { QProcess open; QStringList args; // force use of Preview for PDFs (Adobe Reader 10.01 crashes) if (url.toLower().endsWith(QString::fromAscii(".pdf"))) { args.append(QString::fromAscii("-a")); args.append(QString::fromAscii("Preview")); args.append(url); } else { args.append(url); } open.start(QString::fromAscii("open"), args); open.waitForFinished(5000); if (open.exitCode() != 0) { // Probably means that the file doesn't have a registered // application or something. QProcess reveal; reveal.startDetached(QString::fromAscii("open"), QStringList() << QString::fromAscii("-R") << url); } return; } #endif if (qurl.isRelative()) { // TODO: this should really be handled within GlobalDisplay -- rather // than checking for a relative URL here GlobalDisplay should determine // that a URL is relative and do the right thing (note this needs to // account for our policy regarding /custom/* urls -- below we allow // these to be opened in a standard browser window to match the // behavior of standard CRAN desktop R). // compute local url QUrl localUrl; localUrl.setScheme(QString::fromAscii("http")); localUrl.setHost(QString::fromAscii("localhost")); localUrl.setPort(options().portNumber().toInt()); localUrl.setEncodedPath(url.toAscii()); // show it in a browser or a secondary window as appropriate if (url.startsWith(QString::fromAscii("custom/")) || url.startsWith(QString::fromAscii("help/"))) { QDesktopServices::openUrl(localUrl); } else { SecondaryWindow* pBrowser = new SecondaryWindow(localUrl); pBrowser->webView()->load(localUrl); pBrowser->show(); pBrowser->activateWindow(); } } else { QDesktopServices::openUrl(qurl); }; }