зеркало из https://github.com/mozilla/pjs.git
Http branch landing: changes to other files (bug 76866) r=gagan,sr=dougt,a=chofmann
This commit is contained in:
Родитель
b5c178a4a8
Коммит
c18fe7ef56
|
@ -24,4 +24,4 @@
|
|||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION NS_LITERAL_STRING(\"%04d%02d%02d\").get()\n", $year, 1+$mon, $mday);
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME NS_LITERAL_STRING("Gecko").get()
|
||||
#define PRODUCT_NAME "Gecko"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
|
@ -46,13 +46,13 @@ nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
|||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub(PRODUCT_VERSION);
|
||||
rv = http->SetProductSub((char*) PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
@ -4341,24 +4341,23 @@ HTMLContentSink::ProcessHTTPHeaders(nsIChannel* aChannel) {
|
|||
nsresult rv=NS_OK;
|
||||
|
||||
if(aChannel) {
|
||||
nsCOMPtr<nsIHTTPChannel> httpchannel(do_QueryInterface(aChannel));
|
||||
nsCOMPtr<nsIHttpChannel> httpchannel(do_QueryInterface(aChannel));
|
||||
if (httpchannel) {
|
||||
char* headers[]={"link","default-style","content-base",0}; // add more http headers if you need
|
||||
char** name=headers;
|
||||
nsXPIDLCString tmp;
|
||||
while(*name) {
|
||||
nsCOMPtr<nsIAtom> key(dont_AddRef(NS_NewAtom(*name++)));
|
||||
if(key) {
|
||||
httpchannel->GetResponseHeader(key, getter_Copies(tmp));
|
||||
if(tmp.get()) {
|
||||
nsAutoString value;
|
||||
value.AssignWithConversion(tmp);
|
||||
ProcessHeaderData(key,value);
|
||||
}
|
||||
httpchannel->GetResponseHeader(*name, getter_Copies(tmp));
|
||||
if(tmp.get()) {
|
||||
nsAutoString value;
|
||||
value.AssignWithConversion(tmp);
|
||||
nsCOMPtr<nsIAtom> key(dont_AddRef(NS_NewAtom(*name)));
|
||||
ProcessHeaderData(key,value);
|
||||
}
|
||||
else {
|
||||
rv=NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
name++;
|
||||
}//while
|
||||
}//if - httpchannel
|
||||
}//if - channel
|
||||
|
@ -4650,7 +4649,7 @@ HTMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||
nsAutoString characterSet;
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder;
|
||||
nsXPIDLCString contenttypeheader;
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
|
@ -4663,10 +4662,7 @@ HTMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||
if (channel) {
|
||||
httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel) {
|
||||
nsCOMPtr<nsIAtom> contentTypeKey =
|
||||
dont_AddRef(NS_NewAtom("content-type"));
|
||||
|
||||
rv = httpChannel->GetResponseHeader(contentTypeKey,
|
||||
rv = httpChannel->GetResponseHeader("content-type",
|
||||
getter_Copies(contenttypeheader));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsISelectElement.h"
|
||||
|
@ -439,19 +439,16 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
}
|
||||
|
||||
nsAutoString lastModified;
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
|
||||
PRBool bTryCache = PR_FALSE;
|
||||
PRUint32 cacheFlags = 0;
|
||||
|
||||
if (httpChannel) {
|
||||
nsXPIDLCString lastModHeader;
|
||||
nsIAtom* lastModKey = NS_NewAtom("last-modified");
|
||||
|
||||
rv = httpChannel->GetResponseHeader(lastModKey,
|
||||
rv = httpChannel->GetResponseHeader("last-modified",
|
||||
getter_Copies(lastModHeader));
|
||||
|
||||
NS_RELEASE(lastModKey);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
lastModified.AssignWithConversion(NS_STATIC_CAST(const char*,
|
||||
lastModHeader));
|
||||
|
@ -461,9 +458,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
nsXPIDLCString referrerHeader;
|
||||
nsAutoString referrer;
|
||||
// The misspelled key 'referer' is as per the HTTP spec
|
||||
nsCOMPtr<nsIAtom> referrerKey(dont_AddRef(NS_NewAtom("referer")));
|
||||
|
||||
rv = httpChannel->GetRequestHeader(referrerKey,
|
||||
rv = httpChannel->GetRequestHeader("referer",
|
||||
getter_Copies(referrerHeader));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -473,11 +468,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
}
|
||||
|
||||
if(kCharsetFromHTTPHeader > charsetSource) {
|
||||
nsCOMPtr<nsIAtom>
|
||||
contentTypeKey(dont_AddRef(NS_NewAtom("content-type")));
|
||||
|
||||
nsXPIDLCString contenttypeheader;
|
||||
rv = httpChannel->GetResponseHeader(contentTypeKey,
|
||||
rv = httpChannel->GetResponseHeader("content-type",
|
||||
getter_Copies(contenttypeheader));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "nsIDOMElement.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsParserCIID.h"
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
#include "nsICSSLoader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -223,7 +223,7 @@ NS_INTERFACE_MAP_BEGIN(nsXMLDocument)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIXMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTMLContentContainer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTTPEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Document)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDocument)
|
||||
|
||||
|
@ -278,15 +278,9 @@ nsXMLDocument::GetInterface(const nsIID& aIID, void** aSink)
|
|||
}
|
||||
|
||||
|
||||
// nsIHTTPEventSink
|
||||
// nsIHttpEventSink
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::OnHeadersAvailable(nsISupports *aContext)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::OnRedirect(nsIChannel *aOldChannel, nsIChannel *aNewChannel)
|
||||
nsXMLDocument::OnRedirect(nsIHttpChannel *aHttpChannel, nsIChannel *aNewChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -305,7 +299,6 @@ nsXMLDocument::OnRedirect(nsIChannel *aOldChannel, nsIChannel *aNewChannel)
|
|||
nsCOMPtr<nsIPrincipal> newCodebase;
|
||||
rv = securityManager->GetCodebasePrincipal(newLocation,
|
||||
getter_AddRefs(newCodebase));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -412,14 +405,12 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
aContentType = nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if(httpChannel) {
|
||||
nsIAtom* contentTypeKey = NS_NewAtom("content-type");
|
||||
nsXPIDLCString contenttypeheader;
|
||||
rv = httpChannel->GetResponseHeader(contentTypeKey, getter_Copies(contenttypeheader));
|
||||
rv = httpChannel->GetResponseHeader("content-type", getter_Copies(contenttypeheader));
|
||||
|
||||
|
||||
NS_RELEASE(contentTypeKey);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoString contentType;
|
||||
contentType.AssignWithConversion( NS_STATIC_CAST(const char*, contenttypeheader) );
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "nsIXMLDocument.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIHTTPEventSink.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
|
@ -38,7 +38,7 @@ class nsXMLDocument : public nsMarkupDocument,
|
|||
public nsIXMLDocument,
|
||||
public nsIHTMLContentContainer,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIHTTPEventSink
|
||||
public nsIHttpEventSink
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIHTTPEventSink.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsISecurityEventSink.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsDocumentCharsetInfoCID.h"
|
||||
|
@ -62,10 +62,9 @@
|
|||
// Helper Classes
|
||||
#include "nsDOMError.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsHTTPEnums.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIDataChannel.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIWebProgress.h"
|
||||
|
@ -275,7 +274,7 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink)
|
|||
return NS_NOINTERFACE;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIProgressEventSink))
|
||||
|| aIID.Equals(NS_GET_IID(nsIHTTPEventSink))
|
||||
|| aIID.Equals(NS_GET_IID(nsIHttpEventSink))
|
||||
|| aIID.Equals(NS_GET_IID(nsIWebProgress))
|
||||
|| aIID.Equals(NS_GET_IID(nsISecurityEventSink))) {
|
||||
nsCOMPtr<nsIURILoader>
|
||||
|
@ -3526,10 +3525,11 @@ nsDocShell::DoURILoad(nsIURI * aURI, nsIURI * aReferrerURI,
|
|||
}
|
||||
channel->SetOriginalURI(aURI);
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel) {
|
||||
nsCOMPtr<nsICachingChannel>
|
||||
cacheChannel(do_QueryInterface(httpChannel));
|
||||
printf(">>> caching channel @%x\n", cacheChannel.get());
|
||||
/* Get the cache Key from SH */
|
||||
nsCOMPtr<nsISupports> cacheKey;
|
||||
if (LSHE) {
|
||||
|
@ -3538,6 +3538,8 @@ nsDocShell::DoURILoad(nsIURI * aURI, nsIURI * aReferrerURI,
|
|||
else if (OSHE) // for reload cases
|
||||
OSHE->GetCacheKey(getter_AddRefs(cacheKey));
|
||||
|
||||
printf(">>> cache key @%x\n", cacheKey.get());
|
||||
|
||||
// figure out if we need to set the post data stream on the channel...
|
||||
// right now, this is only done for http channels.....
|
||||
if (aPostData) {
|
||||
|
@ -3550,8 +3552,6 @@ nsDocShell::DoURILoad(nsIURI * aURI, nsIURI * aReferrerURI,
|
|||
postDataRandomAccess->Seek(PR_SEEK_SET, 0);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> method = NS_NewAtom("POST");
|
||||
httpChannel->SetRequestMethod(method);
|
||||
httpChannel->SetUploadStream(aPostData);
|
||||
/* If there is a valid postdata *and* it is a History Load,
|
||||
* set up the cache key on the channel, to retrieve the
|
||||
|
@ -3584,7 +3584,7 @@ nsDocShell::DoURILoad(nsIURI * aURI, nsIURI * aReferrerURI,
|
|||
// Set the referrer explicitly
|
||||
if (aReferrerURI) // Referrer is currenly only set for link clicks here.
|
||||
httpChannel->SetReferrer(aReferrerURI,
|
||||
nsIHTTPChannel::REFERRER_LINK_CLICK);
|
||||
nsIHttpChannel::REFERRER_LINK_CLICK);
|
||||
}
|
||||
else {
|
||||
// iff we are dealing with a JS or a data url, we may need an inherited owner.
|
||||
|
@ -3707,7 +3707,7 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData,
|
|||
if (nsnull == aHeadersData || nsnull == aGenericChannel) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsCOMPtr<nsIHTTPChannel> aChannel = do_QueryInterface(aGenericChannel);
|
||||
nsCOMPtr<nsIHttpChannel> aChannel = do_QueryInterface(aGenericChannel);
|
||||
if (!aChannel) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -3725,7 +3725,6 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData,
|
|||
nsCAutoString headerValue;
|
||||
PRInt32 crlf = 0;
|
||||
PRInt32 colon = 0;
|
||||
nsCOMPtr<nsIAtom> headerAtom;
|
||||
|
||||
//
|
||||
// Suck all the data out of the nsIInputStream into a char * buffer.
|
||||
|
@ -3752,7 +3751,7 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData,
|
|||
|
||||
//
|
||||
// Iterate over the nsString: for each "\r\n" delimeted chunk,
|
||||
// add the value as a header to the nsIHTTPChannel
|
||||
// add the value as a header to the nsIHttpChannel
|
||||
//
|
||||
|
||||
while (PR_TRUE) {
|
||||
|
@ -3772,17 +3771,12 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData,
|
|||
oneHeader.Left(headerName, colon);
|
||||
colon++;
|
||||
oneHeader.Mid(headerValue, colon, oneHeader.Length() - colon);
|
||||
headerAtom = dont_AddRef(NS_NewAtom(headerName.get()));
|
||||
if (!headerAtom) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto AHTC_CLEANUP;
|
||||
}
|
||||
|
||||
//
|
||||
// FINALLY: we can set the header!
|
||||
//
|
||||
|
||||
rv = aChannel->SetRequestHeader(headerAtom, headerValue.get());
|
||||
rv = aChannel->SetRequestHeader(headerName.get(), headerValue.get());
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
goto AHTC_CLEANUP;
|
||||
|
@ -4030,7 +4024,7 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel,
|
|||
// Get the post data from the channel
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
if (aChannel) {
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(aChannel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
|
||||
|
||||
if (httpChannel) {
|
||||
httpChannel->GetUploadStream(getter_AddRefs(inputStream));
|
||||
|
@ -4254,7 +4248,7 @@ NS_IMETHODIMP nsDocShell::SetupRefreshURI(nsIChannel * aChannel)
|
|||
{
|
||||
nsresult
|
||||
rv;
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(aChannel, &rv));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
rv = httpChannel->GetReferrer(getter_AddRefs(referrer));
|
||||
|
@ -4262,11 +4256,8 @@ NS_IMETHODIMP nsDocShell::SetupRefreshURI(nsIChannel * aChannel)
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
SetReferrerURI(referrer);
|
||||
|
||||
nsCOMPtr<nsIAtom>
|
||||
refreshAtom(dont_AddRef(NS_NewAtom("refresh")));
|
||||
nsXPIDLCString
|
||||
refreshHeader;
|
||||
rv = httpChannel->GetResponseHeader(refreshAtom,
|
||||
nsXPIDLCString refreshHeader;
|
||||
rv = httpChannel->GetResponseHeader("refresh",
|
||||
getter_Copies(refreshHeader));
|
||||
|
||||
if (refreshHeader)
|
||||
|
@ -4408,7 +4399,7 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
|
|||
if (cacheChannel) {
|
||||
cacheChannel->GetCacheKey(getter_AddRefs(cacheKey));
|
||||
}
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(aChannel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
|
||||
|
||||
if (httpChannel) {
|
||||
httpChannel->GetUploadStream(getter_AddRefs(inputStream));
|
||||
|
|
|
@ -103,8 +103,7 @@ typedef unsigned long HMTX;
|
|||
#include "nsIFocusController.h"
|
||||
#include "nsIFileStream.h"
|
||||
|
||||
#include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface
|
||||
#include "nsHTTPEnums.h"
|
||||
#include "nsIHttpChannel.h" // add this to the ick include list...we need it to QI for post data interface
|
||||
|
||||
|
||||
#include "nsILocaleService.h"
|
||||
|
@ -1109,7 +1108,7 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
|||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
if (channel) {
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
|
||||
if(httpChannel) {
|
||||
httpChannel->GetUploadStream(getter_AddRefs(inputStream));
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
|
@ -122,7 +122,7 @@ nsIXPConnect *GlobalWindowImpl::sXPConnect = nsnull;
|
|||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kJVMServiceCID, NS_JVMMANAGER_CID);
|
||||
static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID);
|
||||
static NS_DEFINE_CID(kHTTPHandlerCID, NS_HTTPPROTOCOLHANDLER_CID);
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID,
|
||||
NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
@ -3753,12 +3753,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetUserAgent(nsAWritableString& aUserAgent)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *ua = nsnull;
|
||||
char *ua = nsnull;
|
||||
res = service->GetUserAgent(&ua);
|
||||
aUserAgent = ua;
|
||||
aUserAgent = NS_ConvertASCIItoUCS2(ua);
|
||||
Recycle(ua);
|
||||
}
|
||||
|
||||
|
@ -3769,12 +3769,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetAppCodeName(nsAWritableString& aAppCodeName)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *appName = nsnull;
|
||||
char *appName = nsnull;
|
||||
res = service->GetAppName(&appName);
|
||||
aAppCodeName = appName;
|
||||
aAppCodeName = NS_ConvertASCIItoUCS2(appName);
|
||||
Recycle(appName);
|
||||
}
|
||||
|
||||
|
@ -3785,12 +3785,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetAppVersion(nsAWritableString& aAppVersion)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *str = nsnull;
|
||||
char *str = nsnull;
|
||||
res = service->GetAppVersion(&str);
|
||||
aAppVersion = str;
|
||||
aAppVersion = NS_ConvertASCIItoUCS2(str);
|
||||
Recycle(str);
|
||||
|
||||
aAppVersion.Append(NS_LITERAL_STRING(" ("));
|
||||
|
@ -3798,7 +3798,7 @@ NavigatorImpl::GetAppVersion(nsAWritableString& aAppVersion)
|
|||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
aAppVersion += str;
|
||||
aAppVersion += NS_ConvertASCIItoUCS2(str);
|
||||
Recycle(str);
|
||||
|
||||
aAppVersion.Append(NS_LITERAL_STRING("; "));
|
||||
|
@ -3806,7 +3806,7 @@ NavigatorImpl::GetAppVersion(nsAWritableString& aAppVersion)
|
|||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
aAppVersion += str;
|
||||
aAppVersion += NS_ConvertASCIItoUCS2(str);
|
||||
Recycle(str);
|
||||
|
||||
aAppVersion.Append(PRUnichar(')'));
|
||||
|
@ -3826,12 +3826,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetLanguage(nsAWritableString& aLanguage)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *lang = nsnull;
|
||||
char *lang = nsnull;
|
||||
res = service->GetLanguage(&lang);
|
||||
aLanguage = lang;
|
||||
aLanguage = NS_ConvertASCIItoUCS2(lang);
|
||||
Recycle(lang);
|
||||
}
|
||||
|
||||
|
@ -3842,7 +3842,7 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetPlatform(nsAWritableString& aPlatform)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
// sorry for the #if platform ugliness, but Communicator is
|
||||
|
@ -3858,9 +3858,9 @@ NavigatorImpl::GetPlatform(nsAWritableString& aPlatform)
|
|||
// XXX Communicator uses compiled-in build-time string defines
|
||||
// to indicate the platform it was compiled *for*, not what it is
|
||||
// currently running *on* which is what this does.
|
||||
PRUnichar *plat = nsnull;
|
||||
char *plat = nsnull;
|
||||
res = service->GetOscpu(&plat);
|
||||
aPlatform = plat;
|
||||
aPlatform = NS_ConvertASCIItoUCS2(plat);
|
||||
Recycle(plat);
|
||||
#endif
|
||||
}
|
||||
|
@ -3872,12 +3872,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetOscpu(nsAWritableString& aOSCPU)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *oscpu = nsnull;
|
||||
char *oscpu = nsnull;
|
||||
res = service->GetOscpu(&oscpu);
|
||||
aOSCPU = oscpu;
|
||||
aOSCPU = NS_ConvertASCIItoUCS2(oscpu);
|
||||
Recycle(oscpu);
|
||||
}
|
||||
|
||||
|
@ -3888,12 +3888,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetVendor(nsAWritableString& aVendor)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *vendor = nsnull;
|
||||
char *vendor = nsnull;
|
||||
res = service->GetVendor(&vendor);
|
||||
aVendor = vendor;
|
||||
aVendor = NS_ConvertASCIItoUCS2(vendor);
|
||||
Recycle(vendor);
|
||||
}
|
||||
|
||||
|
@ -3905,12 +3905,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetVendorSub(nsAWritableString& aVendorSub)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *vendor = nsnull;
|
||||
char *vendor = nsnull;
|
||||
res = service->GetVendorSub(&vendor);
|
||||
aVendorSub = vendor;
|
||||
aVendorSub = NS_ConvertASCIItoUCS2(vendor);
|
||||
Recycle(vendor);
|
||||
}
|
||||
|
||||
|
@ -3921,12 +3921,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetProduct(nsAWritableString& aProduct)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *product = nsnull;
|
||||
char *product = nsnull;
|
||||
res = service->GetProduct(&product);
|
||||
aProduct = product;
|
||||
aProduct = NS_ConvertASCIItoUCS2(product);
|
||||
Recycle(product);
|
||||
}
|
||||
|
||||
|
@ -3937,12 +3937,12 @@ NS_IMETHODIMP
|
|||
NavigatorImpl::GetProductSub(nsAWritableString& aProductSub)
|
||||
{
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIHTTPProtocolHandler>
|
||||
nsCOMPtr<nsIHttpProtocolHandler>
|
||||
service(do_GetService(kHTTPHandlerCID, &res));
|
||||
if (NS_SUCCEEDED(res) && service) {
|
||||
PRUnichar *productSub = nsnull;
|
||||
char *productSub = nsnull;
|
||||
res = service->GetProductSub(&productSub);
|
||||
aProductSub = productSub;
|
||||
aProductSub = NS_ConvertASCIItoUCS2(productSub);
|
||||
Recycle(productSub);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFileTransportService.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#include "nsCExternalHandlerService.h"
|
||||
|
@ -145,7 +145,7 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa
|
|||
// Post data
|
||||
if (aPostData)
|
||||
{
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(inputChannel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(inputChannel));
|
||||
if (httpChannel)
|
||||
{
|
||||
nsCOMPtr<nsIRandomAccessStore> stream(do_QueryInterface(aPostData));
|
||||
|
@ -155,8 +155,6 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa
|
|||
stream->Seek(PR_SEEK_SET, 0);
|
||||
// Attach the postdata to the http channel
|
||||
httpChannel->SetUploadStream(aPostData);
|
||||
nsCOMPtr<nsIAtom> method = NS_NewAtom("POST");
|
||||
httpChannel->SetRequestMethod(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "nsCookieService.h" /* don't remove -- needed for mac build */
|
||||
#include "nsCookieHTTPNotify.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsCookie.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
|
@ -36,7 +36,7 @@
|
|||
#include "nsINetModuleMgr.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIHTTPProtocolHandler.h" // for NS_HTTP_STARTUP_CATEGORY
|
||||
#include "nsIHttpProtocolHandler.h" // for NS_HTTP_STARTUP_CATEGORY
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIPrompt.h"
|
||||
|
||||
|
@ -45,7 +45,7 @@ static NS_DEFINE_CID(kINetModuleMgrCID, NS_NETMODULEMGR_CID);
|
|||
///////////////////////////////////
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsCookieHTTPNotify, nsIHTTPNotify, nsINetNotify);
|
||||
NS_IMPL_ISUPPORTS2(nsCookieHTTPNotify, nsIHttpNotify, nsINetNotify);
|
||||
|
||||
///////////////////////////////////
|
||||
// nsCookieHTTPNotify Implementation
|
||||
|
@ -96,23 +96,16 @@ NS_METHOD nsCookieHTTPNotify::UnregisterProc(nsIComponentManager *aCompMgr,
|
|||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::Init()
|
||||
{
|
||||
mCookieHeader = getter_AddRefs(NS_NewAtom("Cookie"));
|
||||
if (!mCookieHeader) return NS_ERROR_OUT_OF_MEMORY;
|
||||
mSetCookieHeader = getter_AddRefs(NS_NewAtom("set-cookie"));
|
||||
if (!mSetCookieHeader) return NS_ERROR_OUT_OF_MEMORY;
|
||||
mExpiresHeader = getter_AddRefs(NS_NewAtom("date"));
|
||||
if (!mExpiresHeader) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Register to handing http requests and responses
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsINetModuleMgr> pNetModuleMgr = do_GetService(kINetModuleMgrCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = pNetModuleMgr->RegisterModule(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_CONTRACTID,
|
||||
(nsIHTTPNotify *)this);
|
||||
(nsIHttpNotify *)this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = pNetModuleMgr->RegisterModule(NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_CONTRACTID,
|
||||
(nsIHTTPNotify *)this);
|
||||
(nsIHttpNotify *)this);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -141,26 +134,23 @@ nsCookieHTTPNotify::SetupCookieService()
|
|||
}
|
||||
|
||||
///////////////////////////////////
|
||||
// nsIHTTPNotify
|
||||
// nsIHttpNotify
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::ModifyRequest(nsISupports *aContext)
|
||||
nsCookieHTTPNotify::OnModifyRequest(nsIHttpChannel *aHttpChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
// Preconditions
|
||||
NS_ENSURE_ARG_POINTER(aContext);
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> pHTTPConnection = do_QueryInterface(aContext, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_ARG_POINTER(aHttpChannel);
|
||||
|
||||
// Get the url
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
rv = pHTTPConnection->GetURI(getter_AddRefs(pURL));
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the original url that the user either typed in or clicked on
|
||||
nsCOMPtr<nsILoadGroup> pLoadGroup;
|
||||
rv = pHTTPConnection->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
rv = aHttpChannel->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
|
@ -175,7 +165,7 @@ nsCookieHTTPNotify::ModifyRequest(nsISupports *aContext)
|
|||
if (pChannel) {
|
||||
rv = pChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
} else {
|
||||
rv = pHTTPConnection->GetURI(getter_AddRefs(pFirstURL));
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -189,36 +179,33 @@ nsCookieHTTPNotify::ModifyRequest(nsISupports *aContext)
|
|||
|
||||
// Set the cookie into the request headers
|
||||
if (cookie && *cookie)
|
||||
rv = pHTTPConnection->SetRequestHeader(mCookieHeader, cookie);
|
||||
rv = aHttpChannel->SetRequestHeader("Cookie", cookie);
|
||||
nsMemory::Free((void *)cookie);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieHTTPNotify::AsyncExamineResponse(nsISupports *aContext)
|
||||
nsCookieHTTPNotify::OnExamineResponse(nsIHttpChannel *aHttpChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
// Preconditions
|
||||
NS_ENSURE_ARG_POINTER(aContext);
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> pHTTPConnection = do_QueryInterface(aContext, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ENSURE_ARG_POINTER(aHttpChannel);
|
||||
|
||||
// Get the Cookie header
|
||||
nsXPIDLCString cookieHeader;
|
||||
rv = pHTTPConnection->GetResponseHeader(mSetCookieHeader, getter_Copies(cookieHeader));
|
||||
rv = aHttpChannel->GetResponseHeader("Set-Cookie", getter_Copies(cookieHeader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!cookieHeader) return NS_OK; // not an error, there's just no header.
|
||||
|
||||
// Get the url
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
rv = pHTTPConnection->GetURI(getter_AddRefs(pURL));
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the original url that the user either typed in or clicked on
|
||||
nsCOMPtr<nsILoadGroup> pLoadGroup;
|
||||
rv = pHTTPConnection->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
rv = aHttpChannel->GetLoadGroup(getter_AddRefs(pLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
if (pLoadGroup) {
|
||||
|
@ -231,7 +218,7 @@ nsCookieHTTPNotify::AsyncExamineResponse(nsISupports *aContext)
|
|||
if (pChannel) {
|
||||
rv = pChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
} else {
|
||||
rv = pHTTPConnection->GetURI(getter_AddRefs(pFirstURL));
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(pFirstURL));
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -241,14 +228,14 @@ nsCookieHTTPNotify::AsyncExamineResponse(nsISupports *aContext)
|
|||
if (pChannel) {
|
||||
pChannel->GetNotificationCallbacks(getter_AddRefs(pInterfaces));
|
||||
} else {
|
||||
pHTTPConnection->GetNotificationCallbacks(getter_AddRefs(pInterfaces));
|
||||
aHttpChannel->GetNotificationCallbacks(getter_AddRefs(pInterfaces));
|
||||
}
|
||||
if (pInterfaces)
|
||||
pInterfaces->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(pPrompter));
|
||||
|
||||
// Get the expires
|
||||
nsXPIDLCString expiresHeader;
|
||||
rv = pHTTPConnection->GetResponseHeader(mExpiresHeader, getter_Copies(expiresHeader));
|
||||
nsXPIDLCString dateHeader;
|
||||
rv = aHttpChannel->GetResponseHeader("Date", getter_Copies(dateHeader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Ensure that we have the cookie service
|
||||
|
@ -256,7 +243,7 @@ nsCookieHTTPNotify::AsyncExamineResponse(nsISupports *aContext)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Save the cookie
|
||||
rv = mCookieService->SetCookieStringFromHttp(pURL, pFirstURL, pPrompter, cookieHeader, expiresHeader);
|
||||
rv = mCookieService->SetCookieStringFromHttp(pURL, pFirstURL, pPrompter, cookieHeader, dateHeader);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define nsCookieHTTPNotify_h___
|
||||
|
||||
#include "nsIHttpNotify.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
|
@ -37,7 +36,7 @@
|
|||
|
||||
struct nsModuleComponentInfo; // forward declaration
|
||||
|
||||
class nsCookieHTTPNotify : public nsIHTTPNotify {
|
||||
class nsCookieHTTPNotify : public nsIHttpNotify {
|
||||
public:
|
||||
|
||||
// nsISupports
|
||||
|
@ -47,8 +46,7 @@ public:
|
|||
NS_IMETHOD Init();
|
||||
|
||||
// nsIHttpNotify methods:
|
||||
NS_IMETHOD ModifyRequest(nsISupports *aContext);
|
||||
NS_IMETHOD AsyncExamineResponse(nsISupports *aContext);
|
||||
NS_DECL_NSIHTTPNOTIFY
|
||||
|
||||
// nsCookieHTTPNotify methods:
|
||||
nsCookieHTTPNotify();
|
||||
|
@ -66,9 +64,6 @@ public:
|
|||
const nsModuleComponentInfo *info);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIAtom> mCookieHeader;
|
||||
nsCOMPtr<nsIAtom> mSetCookieHeader;
|
||||
nsCOMPtr<nsIAtom> mExpiresHeader;
|
||||
nsCOMPtr<nsICookieService> mCookieService;
|
||||
|
||||
NS_IMETHOD SetupCookieService();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIHTTPChannel;
|
||||
interface nsIHttpChannel;
|
||||
|
||||
[scriptable, uuid(b7215e70-4157-11d4-9a42-000064657374)]
|
||||
interface nsIXMLHttpRequest : nsISupports {
|
||||
|
@ -50,7 +50,7 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
* for the request. NULL if the HTTP channel has not yet been
|
||||
* created.
|
||||
*/
|
||||
readonly attribute nsIHTTPChannel channel;
|
||||
readonly attribute nsIHttpChannel channel;
|
||||
|
||||
/**
|
||||
* The response to the HTTP request is parsed as if it were a
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "nsXMLHttpRequest.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIHTTPHeader.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIByteArrayInputStream.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
|
@ -579,8 +578,8 @@ nsXMLHttpRequest::SetOnerror(nsISupports * aOnerror)
|
|||
return AddEventListener(ERRORSTR, listener, PR_TRUE);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIHTTPChannel channel; */
|
||||
NS_IMETHODIMP nsXMLHttpRequest::GetChannel(nsIHTTPChannel **aChannel)
|
||||
/* readonly attribute nsIHttpChannel channel; */
|
||||
NS_IMETHODIMP nsXMLHttpRequest::GetChannel(nsIHttpChannel **aChannel)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
*aChannel = mChannel;
|
||||
|
@ -611,14 +610,10 @@ nsXMLHttpRequest::DetectCharset(nsAWritableString& aCharset)
|
|||
{
|
||||
aCharset.Truncate();
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(mChannel,&rv));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel,&rv));
|
||||
if(httpChannel) {
|
||||
nsIAtom* contentTypeKey = NS_NewAtom("content-type");
|
||||
if (!contentTypeKey)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsXPIDLCString contenttypeheader;
|
||||
rv = httpChannel->GetResponseHeader(contentTypeKey, getter_Copies(contenttypeheader));
|
||||
NS_RELEASE(contentTypeKey);
|
||||
rv = httpChannel->GetResponseHeader("content-type", getter_Copies(contenttypeheader));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoString contentType;
|
||||
contentType.AssignWithConversion( NS_STATIC_CAST(const char*, contenttypeheader) );
|
||||
|
@ -772,7 +767,7 @@ nsXMLHttpRequest::GetStatusText(char * *aStatusText)
|
|||
NS_ENSURE_ARG_POINTER(aStatusText);
|
||||
*aStatusText = nsnull;
|
||||
if (mChannel) {
|
||||
return mChannel->GetResponseString(aStatusText);
|
||||
return mChannel->GetResponseStatusText(aStatusText);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -796,34 +791,18 @@ nsXMLHttpRequest::GetAllResponseHeaders(char **_retval)
|
|||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = nsnull;
|
||||
if (mChannel) {
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
nsCAutoString headers;
|
||||
nsHeaderVisitor *visitor = nsnull;
|
||||
NS_NEWXPCOM(visitor, nsHeaderVisitor);
|
||||
if (!visitor)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(visitor);
|
||||
|
||||
nsresult rv = mChannel->GetResponseHeaderEnumerator(getter_AddRefs(enumerator));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool hasMore;
|
||||
while(NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> isup;
|
||||
|
||||
rv = enumerator->GetNext(getter_AddRefs(isup));
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIHTTPHeader> header(do_QueryInterface(isup));
|
||||
if (header) {
|
||||
nsXPIDLCString name, value;
|
||||
header->GetFieldName(getter_Copies(name));
|
||||
header->GetValue(getter_Copies(value));
|
||||
headers.Append((const char*)name);
|
||||
headers.Append(": ");
|
||||
headers.Append((const char*)value);
|
||||
headers.Append("\n");
|
||||
}
|
||||
}
|
||||
*_retval = headers.ToNewCString();
|
||||
nsresult rv = mChannel->VisitResponseHeaders(visitor);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*_retval = ToNewCString(visitor->Headers());
|
||||
|
||||
NS_RELEASE(visitor);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -837,10 +816,8 @@ nsXMLHttpRequest::GetResponseHeader(const char *header, char **_retval)
|
|||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
if (mChannel) {
|
||||
nsCOMPtr<nsIAtom> headerAtom = dont_AddRef(NS_NewAtom(header));
|
||||
return mChannel->GetResponseHeader(headerAtom, _retval);
|
||||
}
|
||||
if (mChannel)
|
||||
return mChannel->GetResponseHeader(header, _retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -905,12 +882,9 @@ nsXMLHttpRequest::OpenRequest(const char *method,
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mChannel->SetAuthTriedWithPrehost(authp);
|
||||
//mChannel->SetAuthTriedWithPrehost(authp);
|
||||
|
||||
nsCOMPtr<nsIAtom> methodAtom = dont_AddRef(NS_NewAtom(method));
|
||||
if (methodAtom) {
|
||||
rv = mChannel->SetRequestMethod(methodAtom);
|
||||
}
|
||||
rv = mChannel->SetRequestMethod(method);
|
||||
|
||||
mStatus = XML_HTTP_REQUEST_OPENED;
|
||||
|
||||
|
@ -1335,10 +1309,8 @@ nsXMLHttpRequest::Send(nsISupports *body)
|
|||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::SetRequestHeader(const char *header, const char *value)
|
||||
{
|
||||
if (mChannel) {
|
||||
nsCOMPtr<nsIAtom> headerAtom = dont_AddRef(NS_NewAtom(header));
|
||||
return mChannel->SetRequestHeader(headerAtom, value);
|
||||
}
|
||||
if (mChannel)
|
||||
return mChannel->SetRequestHeader(header, value);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1473,3 +1445,15 @@ nsXMLHttpRequest::CanSetProperty(const nsIID * iid, const PRUnichar *propertyNam
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXMLHttpRequest::nsHeaderVisitor, nsIHttpHeaderVisitor)
|
||||
|
||||
NS_IMETHODIMP nsXMLHttpRequest::
|
||||
nsHeaderVisitor::VisitHeader(const char *header, const char *value)
|
||||
{
|
||||
mHeaders.Append(header);
|
||||
mHeaders.Append(": ");
|
||||
mHeaders.Append(value);
|
||||
mHeaders.Append('\n');
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#ifdef IMPLEMENT_SYNC_LOAD
|
||||
|
@ -102,7 +102,7 @@ protected:
|
|||
nsIInputStream** aStream);
|
||||
|
||||
nsCOMPtr<nsISupports> mContext;
|
||||
nsCOMPtr<nsIHTTPChannel> mChannel;
|
||||
nsCOMPtr<nsIHttpChannel> mChannel;
|
||||
nsCOMPtr<nsIRequest> mReadRequest;
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
|
@ -122,6 +122,18 @@ protected:
|
|||
PRUint32 count,
|
||||
PRUint32 *writeCount);
|
||||
|
||||
// used to implement getAllResponseHeaders()
|
||||
class nsHeaderVisitor : public nsIHttpHeaderVisitor {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIHTTPHEADERVISITOR
|
||||
nsHeaderVisitor() { NS_INIT_ISUPPORTS(); }
|
||||
virtual ~nsHeaderVisitor() {}
|
||||
const nsACString &Headers() { return mHeaders; }
|
||||
private:
|
||||
nsCString mHeaders;
|
||||
};
|
||||
|
||||
#if 1 // When nsCString::Append()/Length() works for strings that contain nulls, remove this buffer impl
|
||||
class ResponseBodyBuffer {
|
||||
public:
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
|
@ -310,7 +310,7 @@ ImageConsumer::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
|
|||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> pHTTPCon(do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(channel));
|
||||
if (pHTTPCon) {
|
||||
pHTTPCon->GetResponseStatus(&httpStatus);
|
||||
if (httpStatus == 404) {
|
||||
|
@ -768,7 +768,7 @@ ImageNetContextImpl::GetURL (ilIURL * aURL,
|
|||
rv = NS_OpenURI(getter_AddRefs(channel), nsurl, nsnull, group, sink, flags);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
// Get the defloadRequest from the loadgroup-
|
||||
|
@ -783,8 +783,7 @@ ImageNetContextImpl::GetURL (ilIURL * aURL,
|
|||
if (NS_SUCCEEDED(reqchannel->GetURI(getter_AddRefs(referrer))))
|
||||
{
|
||||
// Set the referrer-
|
||||
httpChannel->SetReferrer(referrer,
|
||||
nsIHTTPChannel::REFERRER_INLINES);
|
||||
httpChannel->SetReferrer(referrer, nsIHttpChannel::REFERRER_INLINES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#include "nsIParser.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
|
@ -58,14 +59,12 @@ NS_IMETHODIMP nsObserverBase::NotifyWebShell(
|
|||
nsCOMPtr<nsIChannel> channel=nsnull;
|
||||
res=bundle->GetDataFromBundle(theChannelKey,getter_AddRefs(channel));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel,&res));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel,&res));
|
||||
if(NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsIAtom> atom=nsnull;
|
||||
httpChannel->GetRequestMethod(getter_AddRefs(atom));
|
||||
if(atom) {
|
||||
nsAutoString method;
|
||||
atom->ToString(method);
|
||||
if(method.EqualsWithConversion("POST"))
|
||||
nsXPIDLCString method;
|
||||
httpChannel->GetRequestMethod(getter_Copies(method));
|
||||
if(method) {
|
||||
if(!PL_strcasecmp(method, "POST"))
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,4 +24,4 @@
|
|||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
|
||||
# localtime returns year minus 1900
|
||||
$year = $year + 1900;
|
||||
printf("#define PRODUCT_VERSION NS_LITERAL_STRING(\"%04d%02d%02d\").get()\n", $year, 1+$mon, $mday);
|
||||
printf("#define PRODUCT_VERSION \"%04d%02d%02d\"\n", $year, 1+$mon, $mday);
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsContentHTTPStartup.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "gbdate.h"
|
||||
|
||||
#define PRODUCT_NAME NS_LITERAL_STRING("Gecko").get()
|
||||
#define PRODUCT_NAME "Gecko"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentHTTPStartup,nsIObserver)
|
||||
|
||||
|
@ -46,13 +46,13 @@ nsContentHTTPStartup::Observe( nsISupports *aSubject,
|
|||
|
||||
nsresult rv = nsnull;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(aSubject));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProduct(PRODUCT_NAME);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = http->SetProductSub(PRODUCT_VERSION);
|
||||
rv = http->SetProductSub((char*) PRODUCT_VERSION);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -98,7 +98,6 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
|||
#include "nsIFileSpec.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsLinebreakConverter.h"
|
||||
|
@ -926,17 +925,22 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
nsCOMPtr<nsIIOService> serv(do_GetService(kIOServiceCID));
|
||||
if (serv && multipartDataFile) {
|
||||
|
||||
multipartDataFile->GetInputStream(getter_AddRefs(postDataStream));
|
||||
|
||||
// XXX NewEncodeStream does nothing
|
||||
#if 0
|
||||
nsCOMPtr<nsIProtocolHandler> pHandler;
|
||||
serv->GetProtocolHandler("http", getter_AddRefs(pHandler));
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http(do_QueryInterface(pHandler));
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http(do_QueryInterface(pHandler));
|
||||
|
||||
nsCOMPtr<nsIInputStream> rawStream;
|
||||
multipartDataFile->GetInputStream(getter_AddRefs(rawStream));
|
||||
|
||||
if (http && rawStream) {
|
||||
http->NewEncodeStream(rawStream, nsIHTTPProtocolHandler::ENCODE_NORMAL,
|
||||
http->NewEncodeStream(rawStream, nsIHttpProtocolHandler::ENCODE_NORMAL,
|
||||
getter_AddRefs(postDataStream));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,10 +39,8 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsHTTPEnums.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIHTTPHeader.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIAbSync.h"
|
||||
#include "nsAbSyncCID.h"
|
||||
|
@ -454,7 +452,7 @@ nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */,
|
|||
mContentType = contentType;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
|
||||
|
@ -698,12 +696,10 @@ nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData)
|
|||
// Tag the post stream onto the channel...but never seemed to work...so putting it
|
||||
// directly on the URL spec
|
||||
//
|
||||
nsCOMPtr<nsIAtom> method = NS_NewAtom ("POST");
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(mChannel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
|
||||
if (!httpChannel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
httpChannel->SetRequestMethod(method);
|
||||
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0)))
|
||||
httpChannel->SetUploadStream(postStream);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "prmem.h"
|
||||
#include "nsMsgSend.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsMailHeaders.h"
|
||||
#include "nsMsgI18N.h"
|
||||
#include "nsIMsgHeaderParser.h"
|
||||
|
@ -44,7 +44,7 @@
|
|||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID);
|
||||
static NS_DEFINE_CID(kHTTPHandlerCID, NS_HTTPPROTOCOLHANDLER_CID);
|
||||
|
||||
//
|
||||
// Hopefully, someone will write and XP call like this eventually!
|
||||
|
@ -431,19 +431,17 @@ mime_generate_headers (nsMsgCompFields *fields,
|
|||
}
|
||||
|
||||
|
||||
NS_WITH_SERVICE(nsIHTTPProtocolHandler, pHTTPHandler, kHTTPHandlerCID, &rv);
|
||||
NS_WITH_SERVICE(nsIHttpProtocolHandler, pHTTPHandler, kHTTPHandlerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pHTTPHandler)
|
||||
{
|
||||
nsXPIDLString userAgentString;
|
||||
nsCAutoString cStr;
|
||||
pHTTPHandler->GetUserAgent(getter_Copies(userAgentString));
|
||||
cStr.AssignWithConversion(userAgentString);
|
||||
nsXPIDLCString userAgentString;
|
||||
pHTTPHandler->GetUserAgent(getter_Copies(userAgentString));
|
||||
|
||||
if (!cStr.IsEmpty())
|
||||
if (userAgentString)
|
||||
{
|
||||
// PUSH_STRING ("X-Mailer: "); // To be more standards compliant
|
||||
PUSH_STRING ("User-Agent: ");
|
||||
PUSH_STRING(cStr);
|
||||
PUSH_STRING(userAgentString.get());
|
||||
PUSH_NEWLINE ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsMsgAttachmentHandler.h"
|
||||
#include "nsMsgSend.h"
|
||||
|
@ -46,7 +46,7 @@
|
|||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS7(nsURLFetcher, nsIURLFetcher, nsIStreamListener, nsIURIContentListener, nsIInterfaceRequestor, nsIWebProgressListener, nsIHTTPEventSink, nsISupportsWeakReference)
|
||||
NS_IMPL_ISUPPORTS7(nsURLFetcher, nsIURLFetcher, nsIStreamListener, nsIURIContentListener, nsIInterfaceRequestor, nsIWebProgressListener, nsIHttpEventSink, nsISupportsWeakReference)
|
||||
|
||||
|
||||
/*
|
||||
|
@ -317,7 +317,7 @@ nsURLFetcher::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsres
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
|
||||
if (httpChannel)
|
||||
{
|
||||
if (NS_SUCCEEDED(httpChannel->GetCharset(&charset)) && charset)
|
||||
|
@ -446,14 +446,7 @@ nsURLFetcher::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnHeadersAvailable(nsISupports *aContext)
|
||||
{
|
||||
/* ignore this event */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnRedirect(nsIChannel *aOldChannel, nsIChannel *aNewChannel)
|
||||
nsURLFetcher::OnRedirect(nsIHttpChannel *aOldChannel, nsIChannel *aNewChannel)
|
||||
{
|
||||
mRedirection = PR_TRUE;
|
||||
return NS_OK;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "nsCURILoader.h"
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIHTTPEventSink.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ class nsURLFetcher : public nsIURLFetcher,
|
|||
public nsIURIContentListener,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIWebProgressListener,
|
||||
public nsIHTTPEventSink,
|
||||
public nsIHttpEventSink,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
// Methods for nsIWebProgressListener
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
// Methods for nsIHTTPEventSink
|
||||
// Methods for nsIHttpEventSink
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
|
||||
private:
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
|
@ -149,7 +149,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgID
|
|||
NS_ADDREF(pl);
|
||||
|
||||
// set the referrer if this is an HTTP request
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(newChannel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(newChannel));
|
||||
if (aLoadGroup && httpChannel) {
|
||||
nsresult rv;
|
||||
// Get the defloadRequest from the loadgroup
|
||||
|
@ -165,8 +165,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgID
|
|||
rv = reqChannel->GetURI(getter_AddRefs(referrer));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Set the referrer
|
||||
httpChannel->SetReferrer(referrer,
|
||||
nsIHTTPChannel::REFERRER_INLINES);
|
||||
httpChannel->SetReferrer(referrer, nsIHttpChannel::REFERRER_INLINES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,7 +234,8 @@ pref("network.http.keep-alive", true); // set it to false in case of problems
|
|||
pref("network.http.proxy.keep-alive", true );
|
||||
pref("network.http.keep-alive.timeout", 300);
|
||||
|
||||
pref("network.http.max-connections", 8);
|
||||
pref("network.http.max-connections", 16);
|
||||
pref("network.http.max-connections-per-server", 8);
|
||||
pref("network.http.keep-alive.max-connections", 20); // max connections to be kept alive
|
||||
pref("network.http.keep-alive.max-connections-per-server", 8);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "nsAutoConfig.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "prmem.h"
|
||||
|
@ -129,7 +129,7 @@ nsAutoConfig::OnStopRequest(nsIRequest* request, nsISupports* context,
|
|||
}
|
||||
|
||||
//Checking for the http response, if failure go read the failover file.
|
||||
nsCOMPtr<nsIHTTPChannel> pHTTPCon(do_QueryInterface(request));
|
||||
nsCOMPtr<nsIHttpChannel> pHTTPCon(do_QueryInterface(request));
|
||||
if (pHTTPCon) {
|
||||
PRUint32 httpStatus;
|
||||
pHTTPCon->GetResponseStatus(&httpStatus);
|
||||
|
|
|
@ -40,7 +40,6 @@ CPPSRCS = \
|
|||
ns4xPluginInstance.cpp \
|
||||
nsPluginDocLoaderFactory.cpp \
|
||||
nsPluginHostImpl.cpp \
|
||||
nsPluginProxyImpl.cpp \
|
||||
nsPluginModule.cpp \
|
||||
nsPluginInstancePeer.cpp \
|
||||
nsPluginViewer.cpp \
|
||||
|
|
|
@ -42,7 +42,6 @@ OBJS = \
|
|||
.\$(OBJDIR)\ns4xPluginInstance.obj \
|
||||
.\$(OBJDIR)\nsPluginDocLoaderFactory.obj \
|
||||
.\$(OBJDIR)\nsPluginHostImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginProxyImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginModule.obj \
|
||||
.\$(OBJDIR)\nsPluginInstancePeer.obj \
|
||||
.\$(OBJDIR)\nsPluginViewer.obj \
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
#include "nsIJVMPlugin.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsIHTTPHeaderListener.h"
|
||||
#include "nsIHTTPHeader.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
@ -49,7 +49,6 @@
|
|||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIFileStream.h" // for nsIRandomAccessStore
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
@ -143,7 +142,8 @@ static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
|||
static NS_DEFINE_IID(kIRequestObserverIID, NS_IREQUESTOBSERVER_IID);
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID);
|
||||
static NS_DEFINE_CID(kHttpHandlerCID, NS_HTTPPROTOCOLHANDLER_CID);
|
||||
static NS_DEFINE_CID(kIHttpHeaderVisitorIID, NS_IHTTPHEADERVISITOR_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIFileUtilitiesIID, NS_IFILEUTILITIES_IID);
|
||||
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
|
@ -1011,7 +1011,8 @@ nsPluginStreamInfo::SetURL(const char* url)
|
|||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsPluginStreamListenerPeer : public nsIStreamListener,
|
||||
public nsIProgressEventSink
|
||||
public nsIProgressEventSink,
|
||||
public nsIHttpHeaderVisitor
|
||||
{
|
||||
public:
|
||||
nsPluginStreamListenerPeer();
|
||||
|
@ -1021,6 +1022,7 @@ public:
|
|||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIHTTPHEADERVISITOR
|
||||
|
||||
// Called by GetURL and PostURL (via NewStream)
|
||||
nsresult Initialize(nsIURI *aURL,
|
||||
|
@ -1038,10 +1040,6 @@ public:
|
|||
|
||||
nsILoadGroup* GetLoadGroup();
|
||||
|
||||
NS_IMETHOD
|
||||
ReadHeadersFromChannelAndPostToListener(nsIHTTPChannel *httpChannel,
|
||||
nsIHTTPHeaderListener *list);
|
||||
|
||||
nsresult SetLocalFile(const char* aFilename);
|
||||
|
||||
private:
|
||||
|
@ -1215,6 +1213,13 @@ nsresult nsPluginStreamListenerPeer::QueryInterface(const nsIID& aIID,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIHttpHeaderVisitorIID))
|
||||
{
|
||||
*aInstancePtrResult = (void *)((nsIHttpHeaderVisitor *)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aInstancePtrResult = (void *)((nsISupports *)((nsIStreamListener *)this));
|
||||
|
@ -1575,16 +1580,15 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
|
||||
// get httpChannel to retrieve some info we need for nsIPluginStreamInfo setup
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
|
||||
/*
|
||||
* Assumption
|
||||
* By the time nsPluginStreamListenerPeer::OnDataAvailable() gets
|
||||
* called, all the headers have been read.
|
||||
*/
|
||||
nsCOMPtr<nsIHTTPHeaderListener> headerListener = do_QueryInterface(mPStreamListener);
|
||||
if (headerListener && httpChannel)
|
||||
ReadHeadersFromChannelAndPostToListener(httpChannel, headerListener);
|
||||
if (httpChannel)
|
||||
httpChannel->VisitResponseHeaders(this);
|
||||
|
||||
mSetUpListener = PR_TRUE;
|
||||
|
||||
|
@ -1593,8 +1597,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
if (httpChannel)
|
||||
{
|
||||
nsXPIDLCString range;
|
||||
nsCOMPtr<nsIAtom> header(dont_AddRef(NS_NewAtom("accept-ranges")));
|
||||
if(NS_SUCCEEDED(httpChannel->GetResponseHeader(header, getter_Copies(range))))
|
||||
if(NS_SUCCEEDED(httpChannel->GetResponseHeader("accept-ranges", getter_Copies(range))))
|
||||
{
|
||||
if (0 == PL_strcmp(range.get(), "bytes"))
|
||||
bSeekable = PR_TRUE;
|
||||
|
@ -1606,8 +1609,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
if (httpChannel)
|
||||
{
|
||||
char * lastModified;
|
||||
nsCOMPtr<nsIAtom> header(dont_AddRef(NS_NewAtom("last-modified")));
|
||||
httpChannel->GetResponseHeader(header, &lastModified);
|
||||
httpChannel->GetResponseHeader("last-modified", &lastModified);
|
||||
if (lastModified)
|
||||
{
|
||||
PRTime time64;
|
||||
|
@ -1666,58 +1668,14 @@ nsPluginStreamListenerPeer::GetLoadGroup()
|
|||
return loadGroup;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginStreamListenerPeer::
|
||||
ReadHeadersFromChannelAndPostToListener(nsIHTTPChannel *httpChannel,
|
||||
nsIHTTPHeaderListener *listener)
|
||||
nsPluginStreamListenerPeer::VisitHeader(const char *header, const char *value)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIHTTPHeaderListener> listener = do_QueryInterface(mPStreamListener);
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
if (NS_FAILED(rv = httpChannel->
|
||||
GetResponseHeaderEnumerator(getter_AddRefs(enumerator)))) {
|
||||
return rv;
|
||||
}
|
||||
PRBool bMoreHeaders;
|
||||
nsCOMPtr<nsISupports> item;
|
||||
nsCOMPtr<nsIHTTPHeader> header;
|
||||
char *name = nsnull;
|
||||
char *val = nsnull;
|
||||
|
||||
while (NS_SUCCEEDED(rv = enumerator->HasMoreElements(&bMoreHeaders))
|
||||
&& (bMoreHeaders == PR_TRUE)) {
|
||||
enumerator->GetNext(getter_AddRefs(item));
|
||||
header = do_QueryInterface(item);
|
||||
NS_ASSERTION(header, "nsPluginHostImpl::ReadHeadersFromChannelAndPostToListener - Bad HTTP header.");
|
||||
if (header) {
|
||||
|
||||
/*
|
||||
|
||||
* Assumption:
|
||||
|
||||
* The return value from nsIHTTPHeader->{GetFieldName,GetValue}()
|
||||
* must be freed.
|
||||
|
||||
*/
|
||||
|
||||
header->GetFieldName(&name);
|
||||
header->GetValue(&val);
|
||||
if (NS_FAILED(rv = listener->NewResponseHeader(name, val))) {
|
||||
break;
|
||||
}
|
||||
nsCRT::free(name);
|
||||
name = nsnull;
|
||||
nsCRT::free(val);
|
||||
val = nsnull;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return listener->NewResponseHeader(header, value);
|
||||
}
|
||||
|
||||
nsresult nsPluginStreamListenerPeer::SetLocalFile(const char* aFilename)
|
||||
|
@ -1940,26 +1898,18 @@ nsresult nsPluginHostImpl::UserAgent(const char **retstring)
|
|||
static char resultString[NS_RETURN_UASTRING_SIZE];
|
||||
nsresult res;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http = do_GetService(kHTTPHandlerCID, &res);
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http = do_GetService(kHttpHandlerCID, &res);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
PRUnichar *UAString = nsnull;
|
||||
res = http->GetUserAgent(&UAString);
|
||||
nsXPIDLCString uaString;
|
||||
res = http->GetUserAgent(getter_Copies(uaString));
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsAutoString ua(UAString);
|
||||
char * newString = ua.ToNewCString();
|
||||
if (!newString)
|
||||
if(NS_RETURN_UASTRING_SIZE > PL_strlen(uaString))
|
||||
{
|
||||
*retstring = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if(NS_RETURN_UASTRING_SIZE > PL_strlen(newString))
|
||||
{
|
||||
PL_strcpy(resultString, newString);
|
||||
PL_strcpy(resultString, uaString);
|
||||
*retstring = resultString;
|
||||
}
|
||||
else
|
||||
|
@ -1967,8 +1917,6 @@ nsresult nsPluginHostImpl::UserAgent(const char **retstring)
|
|||
*retstring = nsnull;
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsCRT::free(newString);
|
||||
}
|
||||
else
|
||||
*retstring = nsnull;
|
||||
|
@ -2229,9 +2177,8 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result)
|
|||
nsCOMPtr<nsIURI> uriIn;
|
||||
nsCOMPtr<nsIProtocolProxyService> proxyService;
|
||||
nsCOMPtr<nsIIOService> ioService;
|
||||
nsPluginProxyImpl protocolProxy;
|
||||
PRBool isProxyEnabled;
|
||||
nsXPIDLCString proxyHost;
|
||||
nsXPIDLCString proxyHost, proxyType;
|
||||
PRInt32 proxyPort;
|
||||
|
||||
proxyService = do_GetService(kProtocolProxyServiceCID, &res);
|
||||
|
@ -2262,25 +2209,20 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result)
|
|||
return res;
|
||||
}
|
||||
|
||||
res = proxyService->ExamineForProxy(uriIn, &protocolProxy);
|
||||
res = proxyService->ExamineForProxy(uriIn,
|
||||
getter_Copies(proxyHost),
|
||||
&proxyPort,
|
||||
getter_Copies(proxyType));
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// set this to false as default, set to true if proxy successfully
|
||||
// obtained.
|
||||
isProxyEnabled = PR_FALSE;
|
||||
if (NS_SUCCEEDED(protocolProxy.GetProxyHost(getter_Copies(proxyHost)))) {
|
||||
if (NS_SUCCEEDED(protocolProxy.GetProxyPort(&proxyPort))) {
|
||||
*result = PR_smprintf("PROXY %s:%d", (const char *) proxyHost,
|
||||
proxyPort);
|
||||
isProxyEnabled = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isProxyEnabled) {
|
||||
*result = PL_strdup("DIRECT");
|
||||
}
|
||||
else {
|
||||
*result = PR_smprintf("PROXY %s:%d", (const char *) proxyHost, proxyPort);
|
||||
}
|
||||
|
||||
if (nsnull == *result) {
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -3962,7 +3904,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
|||
}
|
||||
|
||||
// deal with headers and post data
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
if(httpChannel)
|
||||
{
|
||||
|
||||
|
@ -4025,8 +3967,6 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
|||
if (postDataRandomAccess)
|
||||
postDataRandomAccess->Seek(PR_SEEK_SET, 0);
|
||||
|
||||
nsCOMPtr<nsIAtom> method(dont_AddRef(NS_NewAtom("POST")));
|
||||
httpChannel->SetRequestMethod(method);
|
||||
httpChannel->SetUploadStream(postDataStream);
|
||||
|
||||
if (newPostData)
|
||||
|
@ -4105,7 +4045,7 @@ nsPluginHostImpl::AddHeadersToChannel(const char *aHeadersData,
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> aChannel = do_QueryInterface(aGenericChannel);
|
||||
nsCOMPtr<nsIHttpChannel> aChannel = do_QueryInterface(aGenericChannel);
|
||||
if (!aChannel) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -4145,17 +4085,12 @@ nsPluginHostImpl::AddHeadersToChannel(const char *aHeadersData,
|
|||
oneHeader.Left(headerName, colon);
|
||||
colon++;
|
||||
oneHeader.Mid(headerValue, colon, oneHeader.Length() - colon);
|
||||
nsCOMPtr<nsIAtom> headerAtom(dont_AddRef(NS_NewAtom(headerName.get())));
|
||||
if (!headerAtom) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//
|
||||
// FINALLY: we can set the header!
|
||||
//
|
||||
|
||||
rv =aChannel->SetRequestHeader(headerAtom, headerValue.get());
|
||||
rv =aChannel->SetRequestHeader(headerName.get(), headerValue.get());
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
|
|
|
@ -40,7 +40,6 @@ CPPSRCS = \
|
|||
ns4xPluginInstance.cpp \
|
||||
nsPluginDocLoaderFactory.cpp \
|
||||
nsPluginHostImpl.cpp \
|
||||
nsPluginProxyImpl.cpp \
|
||||
nsPluginModule.cpp \
|
||||
nsPluginInstancePeer.cpp \
|
||||
nsPluginViewer.cpp \
|
||||
|
|
|
@ -42,7 +42,6 @@ OBJS = \
|
|||
.\$(OBJDIR)\ns4xPluginInstance.obj \
|
||||
.\$(OBJDIR)\nsPluginDocLoaderFactory.obj \
|
||||
.\$(OBJDIR)\nsPluginHostImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginProxyImpl.obj \
|
||||
.\$(OBJDIR)\nsPluginModule.obj \
|
||||
.\$(OBJDIR)\nsPluginInstancePeer.obj \
|
||||
.\$(OBJDIR)\nsPluginViewer.obj \
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
#include "nsIJVMPlugin.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsIHTTPHeaderListener.h"
|
||||
#include "nsIHTTPHeader.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
@ -49,7 +49,6 @@
|
|||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIFileStream.h" // for nsIRandomAccessStore
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
@ -143,7 +142,8 @@ static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
|
|||
static NS_DEFINE_IID(kIRequestObserverIID, NS_IREQUESTOBSERVER_IID);
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID);
|
||||
static NS_DEFINE_CID(kHttpHandlerCID, NS_HTTPPROTOCOLHANDLER_CID);
|
||||
static NS_DEFINE_CID(kIHttpHeaderVisitorIID, NS_IHTTPHEADERVISITOR_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIFileUtilitiesIID, NS_IFILEUTILITIES_IID);
|
||||
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
|
@ -1011,7 +1011,8 @@ nsPluginStreamInfo::SetURL(const char* url)
|
|||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsPluginStreamListenerPeer : public nsIStreamListener,
|
||||
public nsIProgressEventSink
|
||||
public nsIProgressEventSink,
|
||||
public nsIHttpHeaderVisitor
|
||||
{
|
||||
public:
|
||||
nsPluginStreamListenerPeer();
|
||||
|
@ -1021,6 +1022,7 @@ public:
|
|||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIHTTPHEADERVISITOR
|
||||
|
||||
// Called by GetURL and PostURL (via NewStream)
|
||||
nsresult Initialize(nsIURI *aURL,
|
||||
|
@ -1038,10 +1040,6 @@ public:
|
|||
|
||||
nsILoadGroup* GetLoadGroup();
|
||||
|
||||
NS_IMETHOD
|
||||
ReadHeadersFromChannelAndPostToListener(nsIHTTPChannel *httpChannel,
|
||||
nsIHTTPHeaderListener *list);
|
||||
|
||||
nsresult SetLocalFile(const char* aFilename);
|
||||
|
||||
private:
|
||||
|
@ -1215,6 +1213,13 @@ nsresult nsPluginStreamListenerPeer::QueryInterface(const nsIID& aIID,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIHttpHeaderVisitorIID))
|
||||
{
|
||||
*aInstancePtrResult = (void *)((nsIHttpHeaderVisitor *)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aInstancePtrResult = (void *)((nsISupports *)((nsIStreamListener *)this));
|
||||
|
@ -1575,16 +1580,15 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
|
||||
// get httpChannel to retrieve some info we need for nsIPluginStreamInfo setup
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
|
||||
/*
|
||||
* Assumption
|
||||
* By the time nsPluginStreamListenerPeer::OnDataAvailable() gets
|
||||
* called, all the headers have been read.
|
||||
*/
|
||||
nsCOMPtr<nsIHTTPHeaderListener> headerListener = do_QueryInterface(mPStreamListener);
|
||||
if (headerListener && httpChannel)
|
||||
ReadHeadersFromChannelAndPostToListener(httpChannel, headerListener);
|
||||
if (httpChannel)
|
||||
httpChannel->VisitResponseHeaders(this);
|
||||
|
||||
mSetUpListener = PR_TRUE;
|
||||
|
||||
|
@ -1593,8 +1597,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
if (httpChannel)
|
||||
{
|
||||
nsXPIDLCString range;
|
||||
nsCOMPtr<nsIAtom> header(dont_AddRef(NS_NewAtom("accept-ranges")));
|
||||
if(NS_SUCCEEDED(httpChannel->GetResponseHeader(header, getter_Copies(range))))
|
||||
if(NS_SUCCEEDED(httpChannel->GetResponseHeader("accept-ranges", getter_Copies(range))))
|
||||
{
|
||||
if (0 == PL_strcmp(range.get(), "bytes"))
|
||||
bSeekable = PR_TRUE;
|
||||
|
@ -1606,8 +1609,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
if (httpChannel)
|
||||
{
|
||||
char * lastModified;
|
||||
nsCOMPtr<nsIAtom> header(dont_AddRef(NS_NewAtom("last-modified")));
|
||||
httpChannel->GetResponseHeader(header, &lastModified);
|
||||
httpChannel->GetResponseHeader("last-modified", &lastModified);
|
||||
if (lastModified)
|
||||
{
|
||||
PRTime time64;
|
||||
|
@ -1666,58 +1668,14 @@ nsPluginStreamListenerPeer::GetLoadGroup()
|
|||
return loadGroup;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginStreamListenerPeer::
|
||||
ReadHeadersFromChannelAndPostToListener(nsIHTTPChannel *httpChannel,
|
||||
nsIHTTPHeaderListener *listener)
|
||||
nsPluginStreamListenerPeer::VisitHeader(const char *header, const char *value)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIHTTPHeaderListener> listener = do_QueryInterface(mPStreamListener);
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
if (NS_FAILED(rv = httpChannel->
|
||||
GetResponseHeaderEnumerator(getter_AddRefs(enumerator)))) {
|
||||
return rv;
|
||||
}
|
||||
PRBool bMoreHeaders;
|
||||
nsCOMPtr<nsISupports> item;
|
||||
nsCOMPtr<nsIHTTPHeader> header;
|
||||
char *name = nsnull;
|
||||
char *val = nsnull;
|
||||
|
||||
while (NS_SUCCEEDED(rv = enumerator->HasMoreElements(&bMoreHeaders))
|
||||
&& (bMoreHeaders == PR_TRUE)) {
|
||||
enumerator->GetNext(getter_AddRefs(item));
|
||||
header = do_QueryInterface(item);
|
||||
NS_ASSERTION(header, "nsPluginHostImpl::ReadHeadersFromChannelAndPostToListener - Bad HTTP header.");
|
||||
if (header) {
|
||||
|
||||
/*
|
||||
|
||||
* Assumption:
|
||||
|
||||
* The return value from nsIHTTPHeader->{GetFieldName,GetValue}()
|
||||
* must be freed.
|
||||
|
||||
*/
|
||||
|
||||
header->GetFieldName(&name);
|
||||
header->GetValue(&val);
|
||||
if (NS_FAILED(rv = listener->NewResponseHeader(name, val))) {
|
||||
break;
|
||||
}
|
||||
nsCRT::free(name);
|
||||
name = nsnull;
|
||||
nsCRT::free(val);
|
||||
val = nsnull;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return listener->NewResponseHeader(header, value);
|
||||
}
|
||||
|
||||
nsresult nsPluginStreamListenerPeer::SetLocalFile(const char* aFilename)
|
||||
|
@ -1940,26 +1898,18 @@ nsresult nsPluginHostImpl::UserAgent(const char **retstring)
|
|||
static char resultString[NS_RETURN_UASTRING_SIZE];
|
||||
nsresult res;
|
||||
|
||||
nsCOMPtr<nsIHTTPProtocolHandler> http = do_GetService(kHTTPHandlerCID, &res);
|
||||
nsCOMPtr<nsIHttpProtocolHandler> http = do_GetService(kHttpHandlerCID, &res);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
PRUnichar *UAString = nsnull;
|
||||
res = http->GetUserAgent(&UAString);
|
||||
nsXPIDLCString uaString;
|
||||
res = http->GetUserAgent(getter_Copies(uaString));
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsAutoString ua(UAString);
|
||||
char * newString = ua.ToNewCString();
|
||||
if (!newString)
|
||||
if(NS_RETURN_UASTRING_SIZE > PL_strlen(uaString))
|
||||
{
|
||||
*retstring = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if(NS_RETURN_UASTRING_SIZE > PL_strlen(newString))
|
||||
{
|
||||
PL_strcpy(resultString, newString);
|
||||
PL_strcpy(resultString, uaString);
|
||||
*retstring = resultString;
|
||||
}
|
||||
else
|
||||
|
@ -1967,8 +1917,6 @@ nsresult nsPluginHostImpl::UserAgent(const char **retstring)
|
|||
*retstring = nsnull;
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsCRT::free(newString);
|
||||
}
|
||||
else
|
||||
*retstring = nsnull;
|
||||
|
@ -2229,9 +2177,8 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result)
|
|||
nsCOMPtr<nsIURI> uriIn;
|
||||
nsCOMPtr<nsIProtocolProxyService> proxyService;
|
||||
nsCOMPtr<nsIIOService> ioService;
|
||||
nsPluginProxyImpl protocolProxy;
|
||||
PRBool isProxyEnabled;
|
||||
nsXPIDLCString proxyHost;
|
||||
nsXPIDLCString proxyHost, proxyType;
|
||||
PRInt32 proxyPort;
|
||||
|
||||
proxyService = do_GetService(kProtocolProxyServiceCID, &res);
|
||||
|
@ -2262,25 +2209,20 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result)
|
|||
return res;
|
||||
}
|
||||
|
||||
res = proxyService->ExamineForProxy(uriIn, &protocolProxy);
|
||||
res = proxyService->ExamineForProxy(uriIn,
|
||||
getter_Copies(proxyHost),
|
||||
&proxyPort,
|
||||
getter_Copies(proxyType));
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// set this to false as default, set to true if proxy successfully
|
||||
// obtained.
|
||||
isProxyEnabled = PR_FALSE;
|
||||
if (NS_SUCCEEDED(protocolProxy.GetProxyHost(getter_Copies(proxyHost)))) {
|
||||
if (NS_SUCCEEDED(protocolProxy.GetProxyPort(&proxyPort))) {
|
||||
*result = PR_smprintf("PROXY %s:%d", (const char *) proxyHost,
|
||||
proxyPort);
|
||||
isProxyEnabled = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isProxyEnabled) {
|
||||
*result = PL_strdup("DIRECT");
|
||||
}
|
||||
else {
|
||||
*result = PR_smprintf("PROXY %s:%d", (const char *) proxyHost, proxyPort);
|
||||
}
|
||||
|
||||
if (nsnull == *result) {
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -3962,7 +3904,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
|||
}
|
||||
|
||||
// deal with headers and post data
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
if(httpChannel)
|
||||
{
|
||||
|
||||
|
@ -4025,8 +3967,6 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
|||
if (postDataRandomAccess)
|
||||
postDataRandomAccess->Seek(PR_SEEK_SET, 0);
|
||||
|
||||
nsCOMPtr<nsIAtom> method(dont_AddRef(NS_NewAtom("POST")));
|
||||
httpChannel->SetRequestMethod(method);
|
||||
httpChannel->SetUploadStream(postDataStream);
|
||||
|
||||
if (newPostData)
|
||||
|
@ -4105,7 +4045,7 @@ nsPluginHostImpl::AddHeadersToChannel(const char *aHeadersData,
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> aChannel = do_QueryInterface(aGenericChannel);
|
||||
nsCOMPtr<nsIHttpChannel> aChannel = do_QueryInterface(aGenericChannel);
|
||||
if (!aChannel) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
@ -4145,17 +4085,12 @@ nsPluginHostImpl::AddHeadersToChannel(const char *aHeadersData,
|
|||
oneHeader.Left(headerName, colon);
|
||||
colon++;
|
||||
oneHeader.Mid(headerValue, colon, oneHeader.Length() - colon);
|
||||
nsCOMPtr<nsIAtom> headerAtom(dont_AddRef(NS_NewAtom(headerName.get())));
|
||||
if (!headerAtom) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//
|
||||
// FINALLY: we can set the header!
|
||||
//
|
||||
|
||||
rv =aChannel->SetRequestHeader(headerAtom, headerValue.get());
|
||||
rv =aChannel->SetRequestHeader(headerName.get(), headerValue.get());
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nsDocLoader.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -43,6 +44,7 @@
|
|||
#include "nsIPresShell.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
|
||||
|
@ -196,7 +198,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocLoaderImpl)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIWebProgress)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTTPEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISecurityEventSink)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -1233,16 +1235,27 @@ void nsDocLoaderImpl::CalculateMaxProgress(PRInt32 *aMax)
|
|||
*aMax = max;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocLoaderImpl::OnHeadersAvailable(nsISupports * aContext)
|
||||
{
|
||||
// right now I don't think we need to do anything special for this case...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocLoaderImpl::OnRedirect(nsIChannel *aOldChannel, nsIChannel *aNewChannel)
|
||||
NS_IMETHODIMP nsDocLoaderImpl::OnRedirect(nsIHttpChannel *aOldChannel, nsIChannel *aNewChannel)
|
||||
{
|
||||
if (aOldChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> oldURI, newURI;
|
||||
|
||||
rv = aOldChannel->GetOriginalURI(getter_AddRefs(oldURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = aNewChannel->GetURI(getter_AddRefs(newURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// verify that this is a legal redirect
|
||||
NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager,
|
||||
NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = securityManager->CheckLoadURI(oldURI, newURI,
|
||||
nsIScriptSecurityManager::DISALLOW_FROM_MAIL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsLoadFlags loadFlags = 0;
|
||||
PRInt32 stateFlags = nsIWebProgressListener::STATE_REDIRECTING |
|
||||
nsIWebProgressListener::STATE_IS_REQUEST;
|
||||
|
@ -1266,7 +1279,6 @@ NS_IMETHODIMP nsDocLoaderImpl::OnRedirect(nsIChannel *aOldChannel, nsIChannel *a
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDocLoaderImpl::OnSecurityChange(nsISupports * aContext,
|
||||
PRInt32 state)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIHTTPEventSink.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsISecurityEventSink.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -54,7 +54,7 @@ class nsDocLoaderImpl : public nsIDocumentLoader,
|
|||
public nsIProgressEventSink,
|
||||
public nsIWebProgress,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIHTTPEventSink,
|
||||
public nsIHttpEventSink,
|
||||
public nsISecurityEventSink
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
|
@ -223,7 +223,7 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest *request, nsISupport
|
|||
// content handler. Just return. This causes the request to be
|
||||
// ignored.
|
||||
//
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(request, &rv));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request, &rv));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRUint32 responseCode = 0;
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
#include "nsMimeTypes.h"
|
||||
// used for http content header disposition information.
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
@ -634,42 +634,38 @@ void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel* aChan
|
|||
// then use the file name suggested there as the preferred file name to SUGGEST to the user.
|
||||
// we shouldn't actually use that without their permission...o.t. just use our temp file
|
||||
// Try to get HTTP channel....if we have a content-disposition header then we can
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
if ( httpChannel )
|
||||
{
|
||||
// Get content-disposition response header and extract a file name if there is one...
|
||||
// content-disposition: has format: disposition-type < ; filename=value >
|
||||
nsCOMPtr<nsIAtom> atom = NS_NewAtom( "content-disposition" );
|
||||
if (atom)
|
||||
nsXPIDLCString disp;
|
||||
nsresult rv = httpChannel->GetResponseHeader( "content-disposition", getter_Copies( disp ) );
|
||||
if ( NS_SUCCEEDED( rv ) && disp )
|
||||
{
|
||||
nsXPIDLCString disp;
|
||||
nsresult rv = httpChannel->GetResponseHeader( atom, getter_Copies( disp ) );
|
||||
if ( NS_SUCCEEDED( rv ) && disp )
|
||||
nsCAutoString dispositionValue;
|
||||
dispositionValue = disp;
|
||||
PRInt32 pos = dispositionValue.Find("filename=", PR_TRUE);
|
||||
if (pos > 0)
|
||||
{
|
||||
nsCAutoString dispositionValue;
|
||||
dispositionValue = disp;
|
||||
PRInt32 pos = dispositionValue.Find("filename=", PR_TRUE);
|
||||
if (pos > 0)
|
||||
// extract everything after the filename= part and treat that as the file name...
|
||||
nsCAutoString dispFileName;
|
||||
dispositionValue.Mid(dispFileName, pos + nsCRT::strlen("filename="), -1);
|
||||
if (!dispFileName.IsEmpty()) // if we got a file name back..
|
||||
{
|
||||
// extract everything after the filename= part and treat that as the file name...
|
||||
nsCAutoString dispFileName;
|
||||
dispositionValue.Mid(dispFileName, pos + nsCRT::strlen("filename="), -1);
|
||||
if (!dispFileName.IsEmpty()) // if we got a file name back..
|
||||
{
|
||||
pos = dispFileName.FindChar(';', PR_TRUE);
|
||||
if (pos > 0)
|
||||
dispFileName.Truncate(pos);
|
||||
pos = dispFileName.FindChar(';', PR_TRUE);
|
||||
if (pos > 0)
|
||||
dispFileName.Truncate(pos);
|
||||
|
||||
// According to RFC 2183, filename can be given as filename=value,
|
||||
// where value is token or quoted-string. See bug 66181.
|
||||
dispFileName.StripChar('"');
|
||||
// According to RFC 2183, filename can be given as filename=value,
|
||||
// where value is token or quoted-string. See bug 66181.
|
||||
dispFileName.StripChar('"');
|
||||
|
||||
// ONLY if we got here, will we remember the suggested file name...
|
||||
mSuggestedFileName.AssignWithConversion(dispFileName);
|
||||
}
|
||||
} // if we found a file name in the header disposition field
|
||||
} // we had a disp header
|
||||
} // we created the atom correctly
|
||||
// ONLY if we got here, will we remember the suggested file name...
|
||||
mSuggestedFileName.AssignWithConversion(dispFileName);
|
||||
}
|
||||
} // if we found a file name in the header disposition field
|
||||
} // we had a disp header
|
||||
} // if we had an http channel
|
||||
}
|
||||
|
||||
|
@ -833,7 +829,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
|
|||
RetargetLoadNotifications(request);
|
||||
// ignore failure...
|
||||
ExtractSuggestedFileNameFromChannel(aChannel);
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
if ( httpChannel )
|
||||
{
|
||||
// Turn off content encoding conversions.
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#include "nsIEventQueueService.h"
|
||||
#include "nsMPFileLocProvider.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsBuildID.h"
|
||||
#include "nsWindowCreator.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
@ -1101,16 +1101,13 @@ static nsresult DumpVersion(char *appname)
|
|||
long buildID = NS_BUILD_ID; // 10-digit number
|
||||
|
||||
// Get httpHandler service.
|
||||
nsCOMPtr <nsIHTTPProtocolHandler> httpHandler(do_GetService("@mozilla.org/network/protocol;1?name=http", &rv));
|
||||
nsCOMPtr <nsIHttpProtocolHandler> httpHandler(do_GetService("@mozilla.org/network/protocol;1?name=http", &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsXPIDLString agent;
|
||||
nsXPIDLCString agent;
|
||||
httpHandler->GetUserAgent(getter_Copies(agent));
|
||||
|
||||
nsCAutoString agentCStr;
|
||||
agentCStr.AssignWithConversion(agent);
|
||||
|
||||
printf("%s", agentCStr.get());
|
||||
printf("%s", agent.get());
|
||||
|
||||
if(buildID) {
|
||||
printf(", build %u\n", (unsigned int)buildID);
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "nsISHistory.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
|
||||
/// Unsorted Includes
|
||||
|
||||
|
|
|
@ -72,13 +72,11 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsHTTPEnums.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIHTTPHeader.h"
|
||||
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
|
@ -1987,15 +1985,11 @@ nsBookmarksService::FireTimer(nsITimer* aTimer, void* aClosure)
|
|||
if (NS_SUCCEEDED(rv = NS_OpenURI(getter_AddRefs(channel), uri, nsnull)))
|
||||
{
|
||||
channel->SetLoadFlags(nsIRequest::VALIDATE_ALWAYS);
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
bmks->htmlSize = 0;
|
||||
nsCOMPtr<nsIAtom> headAtom = getter_AddRefs(NS_NewAtom("HEAD"));
|
||||
if (headAtom)
|
||||
{
|
||||
httpChannel->SetRequestMethod(headAtom);
|
||||
}
|
||||
httpChannel->SetRequestMethod("HEAD");
|
||||
if (NS_SUCCEEDED(rv = channel->AsyncOpen(bmks, nsnull)))
|
||||
{
|
||||
bmks->busySchedule = PR_TRUE;
|
||||
|
@ -2065,61 +2059,19 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt,
|
|||
#endif
|
||||
}
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel)
|
||||
{
|
||||
nsCAutoString eTagValue, lastModValue, contentLengthValue;
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
if (NS_SUCCEEDED(rv = httpChannel->GetResponseHeaderEnumerator(getter_AddRefs(enumerator))))
|
||||
{
|
||||
PRBool bMoreHeaders;
|
||||
|
||||
while (NS_SUCCEEDED(rv = enumerator->HasMoreElements(&bMoreHeaders))
|
||||
&& (bMoreHeaders == PR_TRUE))
|
||||
{
|
||||
nsCOMPtr<nsISupports> item;
|
||||
enumerator->GetNext(getter_AddRefs(item));
|
||||
nsCOMPtr<nsIHTTPHeader> header = do_QueryInterface(item);
|
||||
NS_ASSERTION(header, "nsBookmarksService::OnStopRequest - Bad HTTP header.");
|
||||
if (header)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> headerAtom;
|
||||
header->GetField(getter_AddRefs(headerAtom));
|
||||
nsAutoString headerStr;
|
||||
headerAtom->ToString(headerStr);
|
||||
|
||||
char *val = nsnull;
|
||||
|
||||
if (headerStr.EqualsIgnoreCase("eTag"))
|
||||
{
|
||||
header->GetValue(&val);
|
||||
if (val)
|
||||
{
|
||||
eTagValue = val;
|
||||
nsCRT::free(val);
|
||||
}
|
||||
}
|
||||
else if (headerStr.EqualsIgnoreCase("Last-Modified"))
|
||||
{
|
||||
header->GetValue(&val);
|
||||
if (val)
|
||||
{
|
||||
lastModValue = val;
|
||||
nsCRT::free(val);
|
||||
}
|
||||
}
|
||||
else if (headerStr.EqualsIgnoreCase("Content-Length"))
|
||||
{
|
||||
header->GetValue(&val);
|
||||
if (val)
|
||||
{
|
||||
contentLengthValue = val;
|
||||
nsCRT::free(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsXPIDLCString val;
|
||||
if (NS_SUCCEEDED(httpChannel->GetResponseHeader("ETag", getter_Copies(val))))
|
||||
eTagValue = val;
|
||||
if (NS_SUCCEEDED(httpChannel->GetResponseHeader("Last-Modified", getter_Copies(val))))
|
||||
lastModValue = val;
|
||||
if (NS_SUCCEEDED(httpChannel->GetResponseHeader("Content-Length", getter_Copies(val))))
|
||||
contentLengthValue = val;
|
||||
val = 0;
|
||||
|
||||
PRBool changedFlag = PR_FALSE;
|
||||
|
||||
|
|
|
@ -58,11 +58,9 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsHTTPEnums.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIBookmarksService.h"
|
||||
#include "nsIHTTPHeader.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIURL.h"
|
||||
|
@ -628,15 +626,11 @@ InternetSearchDataSource::FireTimer(nsITimer* aTimer, void* aClosure)
|
|||
|
||||
channel->SetLoadFlags(nsIRequest::VALIDATE_ALWAYS);
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel (do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel (do_QueryInterface(channel));
|
||||
if (!httpChannel) return;
|
||||
|
||||
// rjc says: just check "HEAD" info for whether a search file has changed
|
||||
nsCOMPtr<nsIAtom> headAtom = getter_AddRefs(NS_NewAtom("HEAD"));
|
||||
if (headAtom)
|
||||
{
|
||||
httpChannel->SetRequestMethod(headAtom);
|
||||
}
|
||||
httpChannel->SetRequestMethod("HEAD");
|
||||
if (NS_SUCCEEDED(rv = channel->AsyncOpen(search, engineContext)))
|
||||
{
|
||||
search->busySchedule = PR_TRUE;
|
||||
|
@ -3551,14 +3545,10 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin
|
|||
{
|
||||
|
||||
// send a "MultiSearch" header
|
||||
nsCOMPtr<nsIHTTPChannel> httpMultiChannel (do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpMultiChannel (do_QueryInterface(channel));
|
||||
if (httpMultiChannel)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> multiSearchAtom = getter_AddRefs(NS_NewAtom("MultiSearch"));
|
||||
if (multiSearchAtom)
|
||||
{
|
||||
httpMultiChannel->SetRequestHeader(multiSearchAtom, "true");
|
||||
}
|
||||
httpMultiChannel->SetRequestHeader("MultiSearch", "true");
|
||||
}
|
||||
|
||||
// get it just from the cache if we can (do not validate)
|
||||
|
@ -3566,21 +3556,17 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin
|
|||
|
||||
if (methodStr.EqualsIgnoreCase("post"))
|
||||
{
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel (do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel (do_QueryInterface(channel));
|
||||
if (httpChannel)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> postAtom = getter_AddRefs(NS_NewAtom("POST"));
|
||||
if (postAtom)
|
||||
{
|
||||
httpChannel->SetRequestMethod(postAtom);
|
||||
}
|
||||
httpChannel->SetRequestMethod("POST");
|
||||
|
||||
// construct post data to send
|
||||
nsAutoString postStr;
|
||||
postStr.AssignWithConversion(POSTHEADER_PREFIX);
|
||||
postStr.AppendInt(input.Length(), 10);
|
||||
postStr.AppendWithConversion(POSTHEADER_SUFFIX);
|
||||
postStr += input;
|
||||
// construct post data to send
|
||||
nsAutoString postStr;
|
||||
postStr.AssignWithConversion(POSTHEADER_PREFIX);
|
||||
postStr.AppendInt(input.Length(), 10);
|
||||
postStr.AppendWithConversion(POSTHEADER_SUFFIX);
|
||||
postStr += input;
|
||||
|
||||
nsCOMPtr<nsIInputStream> postDataStream;
|
||||
nsCAutoString poststrC;
|
||||
|
@ -4443,7 +4429,7 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
|
|||
else if (contextType == nsIInternetSearchContext::ENGINE_DOWNLOAD_CONTEXT ||
|
||||
contextType == nsIInternetSearchContext::ICON_DOWNLOAD_CONTEXT)
|
||||
{
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel (do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel (do_QueryInterface(channel));
|
||||
if (!httpChannel) return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// check HTTP status to ensure success
|
||||
|
@ -4470,7 +4456,7 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
|
|||
busyResource = nsnull;
|
||||
|
||||
// we only have HTTP "HEAD" information when doing updates
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel (do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel (do_QueryInterface(channel));
|
||||
if (!httpChannel) return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// check HTTP status to ensure success
|
||||
|
@ -4482,51 +4468,12 @@ InternetSearchDataSource::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
|
|||
// get last-modified & content-length info
|
||||
nsCAutoString lastModValue, contentLengthValue;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
if (NS_FAILED(rv = httpChannel->GetResponseHeaderEnumerator(getter_AddRefs(enumerator))))
|
||||
return(rv);
|
||||
PRBool bMoreHeaders;
|
||||
while (NS_SUCCEEDED(rv = enumerator->HasMoreElements(&bMoreHeaders))
|
||||
&& (bMoreHeaders == PR_TRUE))
|
||||
{
|
||||
nsCOMPtr<nsISupports> item;
|
||||
enumerator->GetNext(getter_AddRefs(item));
|
||||
nsCOMPtr<nsIHTTPHeader> header (do_QueryInterface(item));
|
||||
NS_ASSERTION(header, "InternetSearchDataSource::OnStopRequest - Bad HTTP header.");
|
||||
if (!header) return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIAtom> headerAtom;
|
||||
header->GetField(getter_AddRefs(headerAtom));
|
||||
nsAutoString headerStr;
|
||||
headerAtom->ToString(headerStr);
|
||||
|
||||
char *val = nsnull;
|
||||
|
||||
if (headerStr.EqualsIgnoreCase("Last-Modified"))
|
||||
{
|
||||
header->GetValue(&val);
|
||||
if (val)
|
||||
{
|
||||
#ifdef DEBUG_SEARCH_UPDATES
|
||||
printf(" Search engine='%s' Last-Modified='%s'\n", engineURI, val);
|
||||
#endif
|
||||
lastModValue = val;
|
||||
nsCRT::free(val);
|
||||
}
|
||||
}
|
||||
else if (headerStr.EqualsIgnoreCase("Content-Length"))
|
||||
{
|
||||
header->GetValue(&val);
|
||||
if (val)
|
||||
{
|
||||
#ifdef DEBUG_SEARCH_UPDATES
|
||||
printf(" Search engine='%s' Content-Length='%s'\n", engineURI, val);
|
||||
#endif
|
||||
contentLengthValue = val;
|
||||
nsCRT::free(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
nsXPIDLCString val;
|
||||
if (NS_SUCCEEDED(httpChannel->GetResponseHeader("Last-Modified", getter_Copies(val))))
|
||||
lastModValue = val;
|
||||
if (NS_SUCCEEDED(httpChannel->GetResponseHeader("Content-Length", getter_Copies(val))))
|
||||
contentLengthValue = val;
|
||||
val = 0;
|
||||
|
||||
// should we fetch the entire file?
|
||||
PRBool updateSearchEngineFile = PR_FALSE;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "nsIChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIRequestObserver.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIExternalHelperAppService.h"
|
||||
|
@ -93,16 +93,13 @@ nsUnknownContentTypeHandler::HandleUnknownContentType( nsIRequest *request,
|
|||
channel = do_QueryInterface( aChannel );
|
||||
|
||||
// Try to get HTTP channel.
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
if ( httpChannel ) {
|
||||
// Get content-disposition response header.
|
||||
nsCOMPtr<nsIAtom> atom = dont_AddRef(NS_NewAtom( "content-disposition" ));
|
||||
if ( atom ) {
|
||||
nsXPIDLCString disp;
|
||||
rv = httpChannel->GetResponseHeader( atom, getter_Copies( disp ) );
|
||||
if ( NS_SUCCEEDED( rv ) && disp ) {
|
||||
contentDisp = disp; // Save the response header to pass to dialog.
|
||||
}
|
||||
nsXPIDLCString disp;
|
||||
rv = httpChannel->GetResponseHeader( "content-disposition", getter_Copies( disp ) );
|
||||
if ( NS_SUCCEEDED( rv ) && disp ) {
|
||||
contentDisp = disp; // Save the response header to pass to dialog.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsIFileStream.h"
|
||||
|
@ -92,25 +92,22 @@ nsStreamTransfer::SelectFileAndTransferLocation( nsIChannel *aChannel, nsIDOMWin
|
|||
nsCAutoString suggestedName;
|
||||
|
||||
// Try to get HTTP channel.
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
if ( httpChannel ) {
|
||||
// Get content-disposition response header.
|
||||
nsCOMPtr<nsIAtom> atom = NS_NewAtom( "content-disposition" );
|
||||
if ( atom ) {
|
||||
nsXPIDLCString disp;
|
||||
nsresult rv = httpChannel->GetResponseHeader( atom, getter_Copies( disp ) );
|
||||
if ( NS_SUCCEEDED( rv ) && disp ) {
|
||||
// Parse out file name.
|
||||
nsCAutoString contentDisp(NS_STATIC_CAST(const char*, disp));
|
||||
// Remove whitespace.
|
||||
contentDisp.StripWhitespace();
|
||||
// Look for ";filename=".
|
||||
char key[] = ";filename=";
|
||||
PRInt32 i = contentDisp.Find( key );
|
||||
if ( i != kNotFound ) {
|
||||
// Name comes after that.
|
||||
suggestedName = contentDisp.get() + i + PL_strlen( key ) + 1;
|
||||
}
|
||||
nsXPIDLCString disp;
|
||||
rv = httpChannel->GetResponseHeader( "content-disposition", getter_Copies( disp ) );
|
||||
if ( NS_SUCCEEDED( rv ) && disp ) {
|
||||
// Parse out file name.
|
||||
nsCAutoString contentDisp(NS_STATIC_CAST(const char*, disp));
|
||||
// Remove whitespace.
|
||||
contentDisp.StripWhitespace();
|
||||
// Look for ";filename=".
|
||||
char key[] = ";filename=";
|
||||
PRInt32 i = contentDisp.Find( key );
|
||||
if ( i != kNotFound ) {
|
||||
// Name comes after that.
|
||||
suggestedName = contentDisp.get() + i + PL_strlen( key ) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +121,6 @@ nsStreamTransfer::SelectFileAndTransferLocation( nsIChannel *aChannel,
|
|||
char const *suggestedName ) {
|
||||
// Prompt the user for the destination file.
|
||||
nsCOMPtr<nsILocalFile> outputFile;
|
||||
PRBool isValid = PR_FALSE;
|
||||
nsresult rv = SelectFile( parent,
|
||||
getter_AddRefs( outputFile ),
|
||||
SuggestNameFor( aChannel, suggestedName ) );
|
||||
|
@ -133,7 +129,7 @@ nsStreamTransfer::SelectFileAndTransferLocation( nsIChannel *aChannel,
|
|||
&&
|
||||
outputFile ) {
|
||||
// Try to get HTTP channel.
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface( aChannel );
|
||||
if ( httpChannel ) {
|
||||
// Turn off content encoding conversions.
|
||||
httpChannel->SetApplyConversion( PR_FALSE );
|
||||
|
@ -183,15 +179,14 @@ nsStreamTransfer::SelectFileAndTransferLocationSpec( char const *aURL,
|
|||
// Post data provided?
|
||||
if ( postData ) {
|
||||
// See if it's an http channel.
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel( do_QueryInterface( channel ) );
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel( do_QueryInterface( channel ) );
|
||||
if ( httpChannel ) {
|
||||
// Rewind stream and attach to channel.
|
||||
nsCOMPtr<nsIRandomAccessStore> stream( do_QueryInterface( postData ) );
|
||||
if ( stream ) {
|
||||
stream->Seek( PR_SEEK_SET, 0 );
|
||||
httpChannel->SetUploadStream( postData );
|
||||
nsCOMPtr<nsIAtom> method = NS_NewAtom ("POST");
|
||||
httpChannel->SetRequestMethod(method);
|
||||
httpChannel->SetRequestMethod("POST");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче