Bug 1173439 P3 Use url query field for database matching and Request creation. r=ehsan

This commit is contained in:
Ben Kelly 2015-06-16 17:39:05 -07:00
parent 610bb60b9c
commit 93ae3fe3a8
2 changed files with 17 additions and 11 deletions

View File

@ -937,19 +937,14 @@ QueryCache(mozIStorageConnection* aConn, CacheId aCacheId,
"LEFT OUTER JOIN response_headers ON entries.id=response_headers.entry_id "
"AND response_headers.name='vary' "
"WHERE entries.cache_id=:cache_id "
"AND entries."
"AND entries.request_url_no_query=:url_no_query "
);
nsAutoCString urlToMatch;
if (aParams.ignoreSearch()) {
urlToMatch = aRequest.urlWithoutQuery();
query.AppendLiteral("request_url_no_query");
} else {
urlToMatch = aRequest.url();
query.AppendLiteral("request_url");
if (!aParams.ignoreSearch()) {
query.AppendLiteral("AND entries.request_url_query=:url_query ");
}
query.AppendLiteral("=:url GROUP BY entries.id ORDER BY entries.id;");
query.AppendLiteral("GROUP BY entries.id ORDER BY entries.id;");
nsCOMPtr<mozIStorageStatement> state;
nsresult rv = aConn->CreateStatement(query, getter_AddRefs(state));
@ -958,9 +953,16 @@ QueryCache(mozIStorageConnection* aConn, CacheId aCacheId,
rv = state->BindInt64ByName(NS_LITERAL_CSTRING("cache_id"), aCacheId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindUTF8StringByName(NS_LITERAL_CSTRING("url"), urlToMatch);
rv = state->BindUTF8StringByName(NS_LITERAL_CSTRING("url_no_query"),
aRequest.urlWithoutQuery());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
if (!aParams.ignoreSearch()) {
rv = state->BindUTF8StringByName(NS_LITERAL_CSTRING("url_query"),
aRequest.urlQuery());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
}
bool hasMoreData = false;
while (NS_SUCCEEDED(state->ExecuteStep(&hasMoreData)) && hasMoreData) {
// no invalid EntryId, init to least likely real value

View File

@ -321,7 +321,11 @@ TypeUtils::ToInternalRequest(const CacheRequest& aIn)
nsRefPtr<InternalRequest> internalRequest = new InternalRequest();
internalRequest->SetMethod(aIn.method());
internalRequest->SetURL(aIn.url());
nsAutoCString url(aIn.urlWithoutQuery());
url.Append(aIn.urlQuery());
internalRequest->SetURL(url);
internalRequest->SetReferrer(aIn.referrer());
internalRequest->SetMode(aIn.mode());
internalRequest->SetCredentialsMode(aIn.credentials());