コード例 #1
0
ファイル: upnphttpclient.cpp プロジェクト: dirkvdb/upnp
std::vector<uint8_t> HttpClient::getData(const std::string& url, uint64_t offset, uint64_t size)
{
    std::vector<uint8_t> data;
    
    int32_t httpStatus = 0;
    int contentLength = 0;
    void* pHandle = nullptr;
    
    try
    {
        pHandle = open(url, contentLength, httpStatus, offset, size);

        data.resize(contentLength);
        read(pHandle, data.data(), contentLength);
        UpnpCloseHttpGet(pHandle);
    }
    catch (std::exception& e)
    {
        UpnpCloseHttpGet(pHandle);
        throw std::logic_error(stringops::format("Failed to read http data from url: %s (%s)", url, e.what()).c_str());
    }
    
    throwOnBadHttpStatus(url, httpStatus);
    
    return data;
}
コード例 #2
0
ファイル: upnphttpclient.cpp プロジェクト: dirkvdb/upnp
size_t HttpClient::getContentLength(const std::string& url)
{
	int32_t httpStatus = 0;
    int contentLength = 0;
	
    void* pHandle = open(url, contentLength, httpStatus);    
    UpnpCloseHttpGet(pHandle);
    
    throwOnBadHttpStatus(url, httpStatus);
    return contentLength;
}
コード例 #3
0
ファイル: upnphttpclient.cpp プロジェクト: dirkvdb/upnp
void HttpClient::getData(const std::string& url, uint8_t* pData)
{
    int32_t httpStatus = 0;
    int contentLength = 0;
    void* pHandle = nullptr;
    
    try
    {
        pHandle = open(url, contentLength, httpStatus);
        read(pHandle, pData, contentLength);
        UpnpCloseHttpGet(pHandle);
    }
    catch (std::exception& e)
    {
        UpnpCloseHttpGet(pHandle);
        throw std::logic_error(stringops::format("Failed to read http data from url: %s (%s)", url, e.what()).c_str());
    }
    
    throwOnBadHttpStatus(url, httpStatus);
}
コード例 #4
0
ファイル: upnphttpclient.cpp プロジェクト: dirkvdb/upnp
std::vector<uint8_t> HttpClient::getData(const std::string& url)
{
    std::vector<uint8_t> data;
    
    int32_t httpStatus = 0;
    int contentLength = 0;
    
    void* pHandle = open(url, contentLength, httpStatus);

	data.resize(contentLength);
    read(pHandle, data.data(), contentLength);
    UpnpCloseHttpGet(pHandle);
    
    throwOnBadHttpStatus(url, httpStatus);
    return data;
}
コード例 #5
0
ファイル: upnphttpclient.cpp プロジェクト: dirkvdb/upnp
std::string HttpClient::getText(const std::string& url)
{
    std::string data;
    int32_t httpStatus = 0;
    int contentLength = 0;
	
    void* pHandle = open(url, contentLength, httpStatus);
    data.resize(contentLength);
    read(pHandle, reinterpret_cast<uint8_t*>(&data.front()), contentLength);
    assert(data[data.size()] == '\0');
    
    UpnpCloseHttpGet(pHandle);
    
    throwOnBadHttpStatus(url, httpStatus);
    return data;
}
コード例 #6
0
ファイル: IUpnp.cpp プロジェクト: searKing/easydlna
ERROR_TYPE IUpnp::CloseHttpGet(IN void *handle)
{
    return (ERROR_TYPE)UpnpCloseHttpGet(handle);
}