Checking in for Gerv. Fix for bug 58040; fix Accept headers to do something useful. r=bbaetz, sr=darin

This commit is contained in:
sfraser%netscape.com 2001-05-17 00:17:34 +00:00
Родитель 9a13e37401
Коммит fdc0c90442
3 изменённых файлов: 23 добавлений и 4 удалений

Просмотреть файл

@ -242,6 +242,9 @@ pref("network.http.keep-alive.max-connections-per-server", 8);
pref("network.http.connect.timeout", 30); // in seconds
pref("network.http.request.timeout", 120); // in seconds
// Accept header
pref("network.http.accept.default", "text/xml;q=1, text/html;q=0.9, image/png;q=1, image/jpeg;q=1, image/gif;q=0.9, text/plain;q=0.8, text/css;q=1, */*;q=0.01");
// Enable http compression: comment this out in case of problems with 1.1
pref("network.http.accept-encoding" ,"gzip,deflate,compress,identity");

Просмотреть файл

@ -23,6 +23,7 @@
* Pierre Phaneuf <pp@ludusdesign.com>
* Christopher Blizzard <blizzard@mozilla.org>
* Adrian Havill <havill@redhat.com>
* Gervase Markham <gerv@gerv.net>
*/
#include "nsHttp.h"
@ -233,11 +234,9 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpHeaderArray *request,
rv = request->SetHeader(nsHttp::User_Agent, UserAgent());
if (NS_FAILED(rv)) return rv;
// MIME based content negotiation lives!
// Add the Accept header:
//
// Send */*. We're no longer chopping MIME-types for acceptance.
// MIME based content negotiation has died.
rv = request->SetHeader(nsHttp::Accept, "*/*");
rv = request->SetHeader(nsHttp::Accept, mAccept.get());
if (NS_FAILED(rv)) return rv;
// Add the Accept-Language header:
@ -1056,6 +1055,14 @@ nsHttpHandler::PrefsChanged(const char *pref)
}
}
if (bChangedAll || PL_strcmp(pref, "network.http.accept.default") == 0) {
nsXPIDLCString accept;
rv = mPrefs->CopyCharPref("network.http.accept.default",
getter_Copies(accept));
if (NS_SUCCEEDED(rv))
SetAccept(accept);
}
if (bChangedAll || PL_strcmp(pref, "network.http.accept-encoding") == 0) {
nsXPIDLCString acceptEncodings;
rv = mPrefs->CopyCharPref("network.http.accept-encoding",
@ -1347,6 +1354,13 @@ nsHttpHandler::SetAcceptCharsets(const char *aAcceptCharsets)
return rv;
}
nsresult
nsHttpHandler::SetAccept(const char *aAccept)
{
mAccept = aAccept;
return NS_OK;
}
nsresult
nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings)
{

Просмотреть файл

@ -170,6 +170,7 @@ private:
void InitUserAgentComponents();
void PrefsChanged(const char *pref = nsnull);
nsresult SetAccept(const char *);
nsresult SetAcceptLanguages(const char *);
nsresult SetAcceptEncodings(const char *);
nsresult SetAcceptCharsets(const char *);
@ -211,6 +212,7 @@ private:
PRInt32 mMaxIdleConnections;
PRInt32 mMaxIdleConnectionsPerServer;
nsCString mAccept;
nsCString mAcceptLanguages;
nsCString mAcceptEncodings;
nsCString mAcceptCharsets;