Add new LastModified option to HttpRequest handling (#4563)
* Add LastModified: option to the HttpOptions and handle it properly in HttpOpRequest::prepareRequest() * grid_name could be empty if an invalid grid was passed in.master
parent
527ee429e6
commit
89c373c20b
|
|
@ -538,6 +538,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
|
||||||
long sslHostV(0L);
|
long sslHostV(0L);
|
||||||
long dnsCacheTimeout(-1L);
|
long dnsCacheTimeout(-1L);
|
||||||
long nobody(0L);
|
long nobody(0L);
|
||||||
|
curl_off_t lastModified(0L);
|
||||||
|
|
||||||
if (mReqOptions)
|
if (mReqOptions)
|
||||||
{
|
{
|
||||||
|
|
@ -546,6 +547,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
|
||||||
sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L;
|
sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L;
|
||||||
dnsCacheTimeout = mReqOptions->getDNSCacheTimeout();
|
dnsCacheTimeout = mReqOptions->getDNSCacheTimeout();
|
||||||
nobody = mReqOptions->getHeadersOnly() ? 1L : 0L;
|
nobody = mReqOptions->getHeadersOnly() ? 1L : 0L;
|
||||||
|
lastModified = (curl_off_t)mReqOptions->getLastModified();
|
||||||
}
|
}
|
||||||
check_curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect);
|
check_curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect);
|
||||||
|
|
||||||
|
|
@ -554,6 +556,17 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
|
||||||
|
|
||||||
check_curl_easy_setopt(mCurlHandle, CURLOPT_NOBODY, nobody);
|
check_curl_easy_setopt(mCurlHandle, CURLOPT_NOBODY, nobody);
|
||||||
|
|
||||||
|
if (lastModified)
|
||||||
|
{
|
||||||
|
check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
|
||||||
|
#if (LIBCURL_VERSION_NUM >= 0x073B00)
|
||||||
|
// requires curl 7.59.0
|
||||||
|
check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMEVALUE_LARGE, lastModified);
|
||||||
|
#else
|
||||||
|
check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMEVALUE, (long)lastModified);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// The Linksys WRT54G V5 router has an issue with frequent
|
// The Linksys WRT54G V5 router has an issue with frequent
|
||||||
// DNS lookups from LAN machines. If they happen too often,
|
// DNS lookups from LAN machines. If they happen too often,
|
||||||
// like for every HTTP request, the router gets annoyed after
|
// like for every HTTP request, the router gets annoyed after
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ HttpOptions::HttpOptions() :
|
||||||
mVerifyPeer(sDefaultVerifyPeer),
|
mVerifyPeer(sDefaultVerifyPeer),
|
||||||
mVerifyHost(false),
|
mVerifyHost(false),
|
||||||
mDNSCacheTimeout(-1L),
|
mDNSCacheTimeout(-1L),
|
||||||
|
mLastModified(0),
|
||||||
mNoBody(false)
|
mNoBody(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
@ -129,6 +130,11 @@ void HttpOptions::setHeadersOnly(bool nobody)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HttpOptions::setLastModified(time_t lastModified)
|
||||||
|
{
|
||||||
|
mLastModified = lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
void HttpOptions::setDefaultSSLVerifyPeer(bool verify)
|
void HttpOptions::setDefaultSSLVerifyPeer(bool verify)
|
||||||
{
|
{
|
||||||
sDefaultVerifyPeer = verify;
|
sDefaultVerifyPeer = verify;
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,13 @@ public:
|
||||||
return mNoBody;
|
return mNoBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default: 0
|
||||||
|
void setLastModified(time_t lastModified);
|
||||||
|
time_t getLastModified() const
|
||||||
|
{
|
||||||
|
return mLastModified;
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets default behavior for verifying that the name in the
|
/// Sets default behavior for verifying that the name in the
|
||||||
/// security certificate matches the name of the host contacted.
|
/// security certificate matches the name of the host contacted.
|
||||||
/// Defaults false if not set, but should be set according to
|
/// Defaults false if not set, but should be set according to
|
||||||
|
|
@ -199,6 +206,7 @@ protected:
|
||||||
bool mVerifyHost;
|
bool mVerifyHost;
|
||||||
int mDNSCacheTimeout;
|
int mDNSCacheTimeout;
|
||||||
bool mNoBody;
|
bool mNoBody;
|
||||||
|
time_t mLastModified;
|
||||||
|
|
||||||
static bool sDefaultVerifyPeer;
|
static bool sDefaultVerifyPeer;
|
||||||
}; // end class HttpOptions
|
}; // end class HttpOptions
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ std::string LLGridManager::getGridLabel(const std::string& grid)
|
||||||
{
|
{
|
||||||
std::string grid_label;
|
std::string grid_label;
|
||||||
std::string grid_name = getGrid(grid);
|
std::string grid_name = getGrid(grid);
|
||||||
if (!grid.empty())
|
if (!grid_name.empty())
|
||||||
{
|
{
|
||||||
grid_label = mGridList[grid_name][GRID_LABEL_VALUE].asString();
|
grid_label = mGridList[grid_name][GRID_LABEL_VALUE].asString();
|
||||||
}
|
}
|
||||||
|
|
@ -466,7 +466,7 @@ std::string LLGridManager::getGridId(const std::string& grid)
|
||||||
{
|
{
|
||||||
std::string grid_id;
|
std::string grid_id;
|
||||||
std::string grid_name = getGrid(grid);
|
std::string grid_name = getGrid(grid);
|
||||||
if (!grid.empty())
|
if (!grid_name.empty())
|
||||||
{
|
{
|
||||||
grid_id = mGridList[grid_name][GRID_ID_VALUE].asString();
|
grid_id = mGridList[grid_name][GRID_ID_VALUE].asString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue