necko - we now set the user agent by default

This commit is contained in:
valeski%netscape.com 1999-07-25 13:54:47 +00:00
Родитель cd09f25002
Коммит be23c919f4
1 изменённых файлов: 15 добавлений и 0 удалений

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

@ -25,6 +25,7 @@
#include "nsIChannel.h" #include "nsIChannel.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsIStreamListener.h" #include "nsIStreamListener.h"
#include "nsIIOService.h"
#include "nsIHttpNotify.h" #include "nsIHttpNotify.h"
#include "nsINetModRegEntry.h" #include "nsINetModRegEntry.h"
@ -354,6 +355,8 @@ nsHTTPChannel::GetResponseDataListener(nsIStreamListener* *aListener)
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID); static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID); static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsHTTPChannel methods: // nsHTTPChannel methods:
@ -369,11 +372,23 @@ nsHTTPChannel::Init()
Set up a request object - later set to a clone of a default Set up a request object - later set to a clone of a default
request from the handler request from the handler
*/ */
nsresult rv;
m_pRequest = new nsHTTPRequest(m_URI); m_pRequest = new nsHTTPRequest(m_URI);
if (m_pRequest == nsnull) if (m_pRequest == nsnull)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(m_pRequest); NS_ADDREF(m_pRequest);
m_pRequest->SetConnection(this); m_pRequest->SetConnection(this);
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
PRUnichar * ua = nsnull;
rv = service->GetUserAgent(&ua);
if (NS_FAILED(rv)) return rv;
nsString2 uaString(ua);
nsCRT::free(ua);
char * uaCString = uaString.ToNewCString();
if (!uaCString) return NS_ERROR_OUT_OF_MEMORY;
m_pRequest->SetUserAgent(uaCString);
nsCRT::free(uaCString);
return NS_OK; return NS_OK;
} }