Skip to content

Commit 89c373c

Browse files
authored
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.
1 parent 527ee42 commit 89c373c

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

indra/llcorehttp/_httpoprequest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
538538
long sslHostV(0L);
539539
long dnsCacheTimeout(-1L);
540540
long nobody(0L);
541+
curl_off_t lastModified(0L);
541542

542543
if (mReqOptions)
543544
{
@@ -546,6 +547,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
546547
sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L;
547548
dnsCacheTimeout = mReqOptions->getDNSCacheTimeout();
548549
nobody = mReqOptions->getHeadersOnly() ? 1L : 0L;
550+
lastModified = (curl_off_t)mReqOptions->getLastModified();
549551
}
550552
check_curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect);
551553

@@ -554,6 +556,17 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
554556

555557
check_curl_easy_setopt(mCurlHandle, CURLOPT_NOBODY, nobody);
556558

559+
if (lastModified)
560+
{
561+
check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
562+
#if (LIBCURL_VERSION_NUM >= 0x073B00)
563+
// requires curl 7.59.0
564+
check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMEVALUE_LARGE, lastModified);
565+
#else
566+
check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMEVALUE, (long)lastModified);
567+
#endif
568+
}
569+
557570
// The Linksys WRT54G V5 router has an issue with frequent
558571
// DNS lookups from LAN machines. If they happen too often,
559572
// like for every HTTP request, the router gets annoyed after

indra/llcorehttp/httpoptions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ HttpOptions::HttpOptions() :
4747
mVerifyPeer(sDefaultVerifyPeer),
4848
mVerifyHost(false),
4949
mDNSCacheTimeout(-1L),
50+
mLastModified(0),
5051
mNoBody(false)
5152
{}
5253

@@ -129,6 +130,11 @@ void HttpOptions::setHeadersOnly(bool nobody)
129130
}
130131
}
131132

133+
void HttpOptions::setLastModified(time_t lastModified)
134+
{
135+
mLastModified = lastModified;
136+
}
137+
132138
void HttpOptions::setDefaultSSLVerifyPeer(bool verify)
133139
{
134140
sDefaultVerifyPeer = verify;

indra/llcorehttp/httpoptions.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ class HttpOptions : private boost::noncopyable
178178
return mNoBody;
179179
}
180180

181+
// Default: 0
182+
void setLastModified(time_t lastModified);
183+
time_t getLastModified() const
184+
{
185+
return mLastModified;
186+
}
187+
181188
/// Sets default behavior for verifying that the name in the
182189
/// security certificate matches the name of the host contacted.
183190
/// Defaults false if not set, but should be set according to
@@ -199,6 +206,7 @@ class HttpOptions : private boost::noncopyable
199206
bool mVerifyHost;
200207
int mDNSCacheTimeout;
201208
bool mNoBody;
209+
time_t mLastModified;
202210

203211
static bool sDefaultVerifyPeer;
204212
}; // end class HttpOptions

indra/newview/llviewernetwork.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ std::string LLGridManager::getGridLabel(const std::string& grid)
450450
{
451451
std::string grid_label;
452452
std::string grid_name = getGrid(grid);
453-
if (!grid.empty())
453+
if (!grid_name.empty())
454454
{
455455
grid_label = mGridList[grid_name][GRID_LABEL_VALUE].asString();
456456
}
@@ -466,7 +466,7 @@ std::string LLGridManager::getGridId(const std::string& grid)
466466
{
467467
std::string grid_id;
468468
std::string grid_name = getGrid(grid);
469-
if (!grid.empty())
469+
if (!grid_name.empty())
470470
{
471471
grid_id = mGridList[grid_name][GRID_ID_VALUE].asString();
472472
}

0 commit comments

Comments
 (0)