Esempio n. 1
0
void Session::Request::fetchAccountCharacters(const QString &accountName,
                                      QVariant data) {
    QUrlQuery query;
    query.addQueryItem("accountName", accountName);
    QUrl url = CharactersUrl();
    url.setQuery(query);

    QNetworkRequest request = createRequest(url);
    setAttribute(&request, UserData, data);
    QNetworkReply *r = _manager->get(request);

    connect(r, &QNetworkReply::finished, this, &Session::Request::Request::onAccountCharactersResult);
}
Esempio n. 2
0
void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
        m_requestEntityBody = FormData::create(data, length);
        if (m_upload)
            m_requestEntityBody->setAlwaysStream(true);
    }

    createRequest(ec);
}
Esempio n. 3
0
void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionState& exceptionState)
{
    if (!initSend(exceptionState))
        return;

    if (areMethodAndURLValidForSend()) {
        m_requestEntityBody = FormData::create(data, length);
        if (m_upload)
            m_requestEntityBody->setAlwaysStream(true);
    }

    createRequest(exceptionState);
}
void SdtpCatalogDataProvider::search( QString query, XFolderList selectedFolders )
{
    QString idString;
    for ( XFolderList::const_iterator it = selectedFolders.constBegin();
          it != selectedFolders.constEnd(); ++it ) {
        idString += QString("%1,").arg((*it)->id());
    }
    idString.chop(1);

    QUrl url( QString(SDTP_URL_SEARCH).arg(query).arg(idString) );

    createRequest(url, Search, NULL);
}
Esempio n. 5
0
void XMLHttpRequest::send(ArrayBuffer* body, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) {
        m_requestEntityBody = FormData::create(body->data(), body->byteLength());
        if (m_upload)
            m_requestEntityBody->setAlwaysStream(true);
    }

    createRequest(ec);
}
Esempio n. 6
0
ExceptionOr<void> XMLHttpRequest::sendBytesData(const void* data, size_t length)
{
    if (auto result = prepareToSend())
        return WTFMove(result.value());

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
        m_requestEntityBody = FormData::create(data, length);
        if (m_upload)
            m_requestEntityBody->setAlwaysStream(true);
    }

    return createRequest();
}
Esempio n. 7
0
void Session::Request::loginWithOAuth(const QString &authorizationCode) {
    QUrl url("https://webdev2.office.grindinggear.com/oauth/token");
    QUrlQuery query;
    query.addQueryItem("client_id", "test");
    query.addQueryItem("client_secret", "testpassword");
    query.addQueryItem("code", authorizationCode);
    query.addQueryItem("grant_type", "authorization_code");
    QNetworkRequest request = createRequest(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QNetworkReply *r = _manager->post(request, query.toString().toUtf8());
    connect(r, &QNetworkReply::finished, this, &Session::Request::Request::onOAuthResultPath);
}
Esempio n. 8
0
PublishOutput AmazonSNSClient::publish(PublishInput publishInput, ActionError& actionError) {
    actionError = NONE_ACTIONERROR;

    PublishOutput publishOutput;
	
    if (!publishInput.requiredAreSet()) {
        actionError = MISSING_REQUIRED_ARGS_ACTIONERROR;
	return publishOutput;
    }
	
    contentType = FORM_TYPE;
    MinimalString payload = publishInput.serialize();
	
    char* request = createRequest(payload);
    char* response = sendData(request);
    delete[] request;
    
    if (response == NULL) {
        actionError = CONNECTION_ACTIONERROR;
        return publishOutput;
    }

    int httpStatusCode = findHttpStatusCode(response);
	
    if (httpStatusCode == 200) {
        char* msgidIdx = strstr(response, "<MessageId>");
        int msgidPos = msgidIdx - response;

        char* msgid = new char[MESSAGEID_BUFFER_LENGTH]();
        strncpy(msgid, response + msgidPos + 11, MESSAGEID_BUFFER_LENGTH - 1);
        msgid[37] = '\0';
		
        publishOutput.setMessageId(msgid);
        return publishOutput;
    }
    
    if (httpStatusCode == 403) {
        char* ts = strstr(response, "earlier than ");
        int pos = ts - response;
    	
        char* newts = new char[EXTRACTED_TIMESTAMP_BUFFER_LENGTH]();
        strncpy(newts, response + pos + 31, EXTRACTED_TIMESTAMP_BUFFER_LENGTH - 1);
        newts[16] = '\0';
    	
        char* time = new char[FORMATTED_TIMESTAMP_BUFFER_LENGTH]();
        sprintf(time, "%.8s%.6s", newts, newts + 9);
        dateTimeProvider->sync(time);
    }
    
    return publishOutput;
}
Esempio n. 9
0
void AssetResourceRequest::doSend() {
    // Make request to atp
    auto assetClient = DependencyManager::get<AssetClient>();
    auto parts = _url.path().split(".", QString::SkipEmptyParts);
    auto hash = parts[0];
    auto extension = parts.length() > 1 ? parts[1] : "";

    if (hash.length() != SHA256_HASH_HEX_LENGTH) {
        _result = InvalidURL;
        _state = Finished;

        emit finished();

        return;
    }

    auto request = assetClient->createRequest(hash, extension);

    if (!request) {
        _result = ServerUnavailable;
        _state = Finished;

        emit finished();

        return;
    }

    connect(request, &AssetRequest::progress, this, &AssetResourceRequest::progress);
    QObject::connect(request, &AssetRequest::finished, [this](AssetRequest* req) mutable {
        Q_ASSERT(_state == InProgress);
        Q_ASSERT(req->getState() == AssetRequest::FINISHED);
        
        switch (req->getError()) {
            case NoError:
                _data = req->getData();
                _result = Success;
                break;
            case AssetNotFound:
                _result = NotFound;
                break;
            default:
                _result = Error;
                break;
        }
        
        _state = Finished;
        emit finished();
    });

    request->start();
}
Esempio n. 10
0
void XMLHttpRequest::send(File* body, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && (m_url.protocolIs("http") || m_url.protocolIs("https"))) {
        // FIXME: Should we set a Content-Type if one is not set.
        // FIXME: add support for uploading bundles.
        m_requestEntityBody = FormData::create();
        m_requestEntityBody->appendFile(body->path(), false);
    }

    createRequest(ec);
}
Esempio n. 11
0
/*  
    function accept(): Request
 */
static EjsRequest *hs_accept(Ejs *ejs, EjsHttpServer *sp, int argc, EjsObj **argv)
{
    HttpConn    *conn;
    MprEvent    event;

    memset(&event, 0, sizeof(MprEvent));
    event.dispatcher = sp->endpoint->dispatcher;
    if ((conn = httpAcceptConn(sp->endpoint, &event)) == 0) {
        /* Just ignore */
        mprError("Cannot accept connection");
        return 0;
    }
    return createRequest(sp, conn);
}
Esempio n. 12
0
void updateTagDBVersion(uint newDBVersion)
{
	if(cache == NULL && immatureCache == NULL)
		return;
	
	sqlite3_stmt * request = createRequest(cache != NULL ? cache : immatureCache, "INSERT OR REPLACE INTO "TABLE_TAG_VERSION" (`"VERSION_COLUMN_NAME"`) VALUES(?1);");

	if(request == NULL)
		return;
	
	sqlite3_bind_int(request, 1, (int32_t) newDBVersion);
	sqlite3_step(request);
	destroyRequest(request);
}
Esempio n. 13
0
void XMLHttpRequest::send(Blob* body, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) {
        // FIXME: Should we set a Content-Type if one is not set.
        // FIXME: add support for uploading bundles.
        m_requestEntityBody = FormData::create();
        m_requestEntityBody->appendItems(body->items());
    }

    createRequest(ec);
}
Esempio n. 14
0
ExceptionOr<void> XMLHttpRequest::send(DOMFormData& body)
{
    if (auto result = prepareToSend())
        return WTFMove(result.value());

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
        m_requestEntityBody = FormData::createMultiPart(body, body.encoding(), document());
        m_requestEntityBody->generateFiles(document());
        if (!m_requestHeaders.contains(HTTPHeaderName::ContentType))
            m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
    }

    return createRequest();
}
Esempio n. 15
0
    int start() {
        // ALOGD("Start debug command");
        WifiRequest request(familyId(), ifaceId());
        int result = createRequest(request);
        if (result != WIFI_SUCCESS) {
            ALOGE("Failed to create debug request; result = %d", result);
            return result;
        }

        result = requestResponse(request);
        if (result != WIFI_SUCCESS) {
            ALOGE("Failed to register debug response; result = %d", result);
        }
        return result;
    }
int main(void)
{
    UnityBegin("DLService.Thingspeak.cpp");

	createRequest();

    RUN_TEST(test_BulkUploadRequestHasCorrectNumberOfLines);
    
 	for (s_testLine = 0; s_testLine < requestStrings.size(); ++s_testLine)
 	{

 		RUN_TEST(test_BulkUploadRequestLineIsCorrect);
 	}

    return 0;
}
Esempio n. 17
0
    int start() {
        ALOGD("Start get packet fate command\n");
        WifiRequest request(familyId(), ifaceId());

        int result = createRequest(request);
        if (result < 0) {
            ALOGE("Failed to create get pkt fate request; result = %d\n", result);
            return result;
        }

        result = requestResponse(request);
        if (result != WIFI_SUCCESS) {
            ALOGE("Failed to register get pkt fate response; result = %d\n", result);
        }
        return result;
    }
Esempio n. 18
0
void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
        m_requestEntityBody = FormData::createMultiPart(*(static_cast<FormDataList*>(body)), body->encoding(), document());

        m_requestEntityBody->generateFiles(document());

        if (!m_requestHeaders.contains(HTTPHeaderName::ContentType))
            m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
    }

    createRequest(ec);
}
Esempio n. 19
0
void Session::Request::fetchAccountStashTabs(const QString &accountName, const QString &league, int tabIndex,
                                     bool tabs, QVariant data) {
    QUrlQuery query;
    query.addQueryItem("accountName", accountName);
    query.addQueryItem("league", league);
    query.addQueryItem("tabIndex", QString::number(tabIndex));
    query.addQueryItem("tabs", tabs ? "1" : "0");
    QUrl url = StashUrl();
    url.setQuery(query);

    QNetworkRequest request = createRequest(url);
    setAttribute(&request, UserData, data);
    setAttribute(&request, League, league);
    QNetworkReply *r = _manager->get(request);

    connect(r, &QNetworkReply::finished, this, &Session::Request::Request::onAccountStashTabsResult);
}
Esempio n. 20
0
void fileReadBytes(WrenVM* vm)
{
  uv_fs_t* request = createRequest(wrenGetSlotValue(vm, 3));

  int fd = *(int*)wrenGetSlotForeign(vm, 0);
  // TODO: Assert fd != -1.

  FileRequestData* data = (FileRequestData*)request->data;
  size_t length = (size_t)wrenGetSlotDouble(vm, 1);
  size_t offset = (size_t)wrenGetSlotDouble(vm, 2);

  data->buffer.len = length;
  data->buffer.base = (char*)malloc(length);

  uv_fs_read(getLoop(), request, fd, &data->buffer, 1, offset,
             fileReadBytesCallback);
}
Esempio n. 21
0
uint getTagDBVersion()
{
	sqlite3_stmt * request = NULL;
	uint output;

	if((cache == NULL && immatureCache == NULL) ||
		(request = createRequest(cache != NULL ? cache : immatureCache, "SELECT `"VERSION_COLUMN_NAME"` FROM "TABLE_TAG_VERSION" LIMIT 1")) == NULL ||
	   	sqlite3_step(request) != SQLITE_ROW)
	{
		output = DEFAULT_TAG_VERSION;
	}
	else
		output = (uint32_t) sqlite3_column_int(request, 0);
	
	destroyRequest(request);
	return output;
}
    virtual int cancel() {
        ALOGD("Disabling Full scan results");

        WifiRequest request(familyId(), ifaceId());
        int result = createRequest(request, GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, 0);
        if (result != WIFI_SUCCESS) {
            ALOGE("failed to create request; result = %d", result);
        } else {
            result = requestResponse(request);
            if (result != WIFI_SUCCESS) {
                ALOGE("failed to disable full scan results;result = %d", result);
            }
        }

        unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);
        return WIFI_SUCCESS;
    }
Esempio n. 23
0
SnapJob * SnapSocket::snapAction(const QString& name, SnapSocket::SnapAction action, const QString& channel)
{
    QString actionStr;
    switch(action) {
        case Install: actionStr = QStringLiteral("install"); break;
        case Refresh: actionStr = QStringLiteral("refresh"); break;
        case Remove: actionStr = QStringLiteral("remove"); break;
        case Revert: actionStr = QStringLiteral("revert"); break;
        case Enable: actionStr = QStringLiteral("enable"); break;
        case Disable: actionStr = QStringLiteral("disable"); break;
        default:
            Q_UNREACHABLE();
    }
    QJsonObject query = {{ QStringLiteral("action"), actionStr }};
    if (!channel.isEmpty())
        query.insert(QStringLiteral("channel"), channel);
    return new AuthSnapJob(createRequest("POST", "/v2/snaps/"+name.toUtf8(), query), this);
}
Esempio n. 24
0
uint getRootCategoryIDForID(uint32_t categoryID)
{
	sqlite3_stmt * request = NULL;
	uint output;

	if(categoryID == CAT_NO_VALUE)
		return CAT_NO_VALUE;

	else if((request = createRequest(cache != NULL ? cache : immatureCache, "SELECT "DBNAMETOID(RDB_CAT_rootID)" FROM "TABLE_CATEGORY" WHERE "DBNAMETOID(RDB_CAT_ID)" = ?1;")) == NULL || sqlite3_step(request) != SQLITE_ROW)
		output = (uint32_t) sqlite3_column_int(request, 0);
	
	else
		output = CAT_NO_VALUE;
	
	destroyRequest(request);

	return output;
}
Esempio n. 25
0
void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) {
        m_requestEntityBody = FormData::createMultiPart(*body, document());

        String contentType = getRequestHeader("Content-Type");
        if (contentType.isEmpty()) {
            contentType = "multipart/form-data; boundary=";
            contentType += m_requestEntityBody->boundary().data();
            setRequestHeaderInternal("Content-Type", contentType);
        }
    }

    createRequest(ec);
}
Esempio n. 26
0
void XMLHttpRequest::send(Blob* body, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) {
        // FIXME: Should we set a Content-Type if one is not set.
        // FIXME: add support for uploading bundles.
        m_requestEntityBody = FormData::create();
#if ENABLE(BLOB_SLICE)
        m_requestEntityBody->appendFileRange(body->path(), body->start(), body->length(), body->modificationTime());
#else
        m_requestEntityBody->appendFile(body->path(), false);
#endif
    }

    createRequest(ec);
}
Esempio n. 27
0
void XMLHttpRequest::send(DOMFormData* body, ExceptionState& exceptionState)
{
    WTF_LOG(Network, "XMLHttpRequest %p send() DOMFormData %p", this, body);

    if (!initSend(exceptionState))
        return;

    if (areMethodAndURLValidForSend()) {
        m_requestEntityBody = body->createMultiPartFormData(body->encoding());

        if (getRequestHeader("Content-Type").isEmpty()) {
            AtomicString contentType = AtomicString("multipart/form-data; boundary=", AtomicString::ConstructFromLiteral) + m_requestEntityBody->boundary().data();
            setRequestHeaderInternal("Content-Type", contentType);
        }
    }

    createRequest(exceptionState);
}
void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraintsData, const WebCore::MediaConstraintsData& videoConstraintsData)
{
#if ENABLE(MEDIA_STREAM)
    auto invalidHandler = [this, userMediaID](const String& invalidConstraint) {
        if (!m_page.isValid())
            return;

        denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::InvalidConstraint, invalidConstraint);
    };

    auto validHandler = [this, userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier](const Vector<String>&& audioDeviceUIDs, const Vector<String>&& videoDeviceUIDs) {
        if (!m_page.isValid())
            return;

        if (videoDeviceUIDs.isEmpty() && audioDeviceUIDs.isEmpty()) {
            denyRequest(userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints, "");
            return;
        }

        auto userMediaOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(userMediaDocumentOriginIdentifier)->securityOrigin());
        auto topLevelOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(topLevelDocumentOriginIdentifier)->securityOrigin());
        auto request = createRequest(userMediaID, audioDeviceUIDs, videoDeviceUIDs);

        if (!m_page.uiClient().decidePolicyForUserMediaPermissionRequest(m_page, *m_page.process().webFrame(frameID), *userMediaOrigin.get(), *topLevelOrigin.get(), request.get())) {
            m_pendingUserMediaRequests.take(userMediaID);
            request->deny(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled);
        }
    };

    auto audioConstraints = MediaConstraintsImpl::create(audioConstraintsData);
    auto videoConstraints = MediaConstraintsImpl::create(videoConstraintsData);

    syncWithWebCorePrefs();
    RealtimeMediaSourceCenter::singleton().validateRequestConstraints(validHandler, invalidHandler, audioConstraints, videoConstraints);
#else
    UNUSED_PARAM(userMediaID);
    UNUSED_PARAM(frameID);
    UNUSED_PARAM(userMediaDocumentOriginIdentifier);
    UNUSED_PARAM(topLevelDocumentOriginIdentifier);
    UNUSED_PARAM(audioConstraintsData);
    UNUSED_PARAM(videoConstraintsData);
#endif
}
Esempio n. 29
0
void XMLHttpRequest::send(Blob* body, ExceptionCode& ec)
{
    if (!initSend(ec))
        return;

    if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) {
        // FIXME: Should we set a Content-Type if one is not set.
        // FIXME: add support for uploading bundles.
        m_requestEntityBody = FormData::create();
        if (body->isFile())
            m_requestEntityBody->appendFile(static_cast<File*>(body)->path());
#if ENABLE(BLOB)
        else
            m_requestEntityBody->appendBlob(body->url());
#endif
    }

    createRequest(ec);
}
Esempio n. 30
0
void AssetScriptingInterface::downloadData(QString urlString, QScriptValue callback) {
    const QString ATP_SCHEME { "atp://" };

    if (!urlString.startsWith(ATP_SCHEME)) {
        return;
    }

    // Make request to atp
    auto path = urlString.right(urlString.length() - ATP_SCHEME.length());
    auto parts = path.split(".", QString::SkipEmptyParts);
    auto hash = parts.length() > 0 ? parts[0] : "";
    auto extension = parts.length() > 1 ? parts[1] : "";

    if (hash.length() != SHA256_HASH_HEX_LENGTH) {
        return;
    }

    auto assetClient = DependencyManager::get<AssetClient>();
    auto assetRequest = assetClient->createRequest(hash, extension);

    if (!assetRequest) {
        return;
    }

    _pendingRequests << assetRequest;

    connect(assetRequest, &AssetRequest::finished, this, [this, callback](AssetRequest* request) mutable {
        Q_ASSERT(request->getState() == AssetRequest::Finished);

        if (request->getError() == AssetRequest::Error::NoError) {
            if (callback.isFunction()) {
                QString data = QString::fromUtf8(request->getData());
                QScriptValueList args { data };
                callback.call(_engine->currentContext()->thisObject(), args);
            }
        }

        request->deleteLater();
        _pendingRequests.remove(request);
    });

    assetRequest->start();
}