Fixed some broken status headers. Added Host: header by default. This was otherwise breaking (as in unsuccessful HTTP) for some sites that use virtual hosts and depend upon the Host: header.

This commit is contained in:
gagan%netscape.com 1999-07-15 22:57:04 +00:00
Родитель bf39a7e9ea
Коммит e2e849d721
7 изменённых файлов: 36 добавлений и 25 удалений

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

@ -297,18 +297,17 @@ nsHTTPChannel::GetResponseHeader(const char* i_Header, char* *o_Value)
if (m_pResponse)
return m_pResponse->GetHeader(i_Header, o_Value);
else
return NS_ERROR_NOT_IMPLEMENTED; // NS_ERROR_NO_RESPONSE_YET ?
return NS_ERROR_FAILURE ; // NS_ERROR_NO_RESPONSE_YET ?
}
NS_IMETHODIMP
nsHTTPChannel::GetResponseStatus(nsresult *o_Status)
nsHTTPChannel::GetResponseStatus(PRUint32 *o_Status)
{
PRInt32 status = -1;
if (!m_bConnected)
Open();
*o_Status = status;
return NS_ERROR_NOT_IMPLEMENTED;
if (m_pResponse)
return m_pResponse->GetStatus(o_Status);
return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ?
}
NS_IMETHODIMP
@ -316,7 +315,9 @@ nsHTTPChannel::GetResponseString(char* *o_String)
{
if (!m_bConnected)
Open();
return NS_ERROR_NOT_IMPLEMENTED;
if (m_pResponse)
return m_pResponse->GetStatusString(o_String);
return NS_ERROR_FAILURE; // NS_ERROR_NO_RESPONSE_YET ?
}
NS_IMETHODIMP

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

@ -49,7 +49,7 @@ public:
nsIHTTPEventSink* i_HTTPEventSink,
nsIHTTPHandler* i_Handler);
~nsHTTPChannel();
virtual ~nsHTTPChannel();
// Functions from nsISupports
NS_DECL_ISUPPORTS
@ -81,7 +81,7 @@ public:
NS_IMETHOD SetRequestHeader(const char *headerName, const char *value);
NS_IMETHOD SetRequestMethod(PRUint32 method);
NS_IMETHOD GetResponseHeader(const char *headerName, char **_retval);
NS_IMETHOD GetResponseStatus(nsresult *aResponseStatus);
NS_IMETHOD GetResponseStatus(PRUint32 *aResponseStatus);
NS_IMETHOD GetResponseString(char * *aResponseString);
NS_IMETHOD GetEventSink(nsIHTTPEventSink* *eventSink);
NS_IMETHOD GetResponseDataListener(nsIStreamListener* *aListener);

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

@ -131,9 +131,9 @@ public:
protected:
// None
private:
nsHTTPHandler(void);
virtual ~nsHTTPHandler();
private:
// This is the array of connections that the handler thread maintains to
// verify unique requests.

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

@ -31,6 +31,7 @@
#include "nsHTTPChannel.h"
#include "nsHTTPResponseListener.h"
#include "nsCRT.h"
#include "nsXPIDLString.h"
#if defined(PR_LOGGING)
extern PRLogModuleInfo* gHTTPLog;
@ -44,7 +45,7 @@ nsHTTPRequest::nsHTTPRequest(nsIURI* i_pURL, HTTPMethod i_Method, nsIChannel* i_
{
NS_INIT_REFCNT();
m_pURL = do_QueryInterface(i_pURL);
m_pURI = do_QueryInterface(i_pURL);
PR_LOG(gHTTPLog, PR_LOG_DEBUG,
("Creating nsHTTPRequest [this=%x].\n", this));
@ -52,7 +53,14 @@ nsHTTPRequest::nsHTTPRequest(nsIURI* i_pURL, HTTPMethod i_Method, nsIChannel* i_
m_pTransport = i_pTransport;
NS_IF_ADDREF(m_pTransport);
//Build();
// Send Host header by default
if (HTTP_ZERO_NINE != m_Version)
{
nsXPIDLCString host;
NS_ASSERTION(m_pURI, "No URI for the request!!");
m_pURI->GetHost(getter_Copies(host));
SetHost(host);
}
}
nsHTTPRequest::~nsHTTPRequest()
@ -93,7 +101,7 @@ nsHTTPRequest::Build()
return NS_ERROR_FAILURE;
}
if (!m_pURL) {
if (!m_pURI) {
NS_ERROR("No URL to build request for!");
return NS_ERROR_NULL_POINTER;
}
@ -121,13 +129,13 @@ nsHTTPRequest::Build()
char* name;
lineBuffer.Append(MethodToString(m_Method));
rv = m_pURL->GetPath(&name);
rv = m_pURI->GetPath(&name);
lineBuffer.Append(name);
nsCRT::free(name);
// Append the Query string if any...
name = nsnull;
rv = m_pURL->GetQuery(&name);
rv = m_pURI->GetQuery(&name);
if (name && *name) {
lineBuffer.Append("?");
lineBuffer.Append(name);

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

@ -294,12 +294,12 @@ protected:
return methods[i_Method];
}
nsCOMPtr<nsIURL> m_pURL;
HTTPVersion m_Version;
HTTPMethod m_Method;
nsCOMPtr<nsIURL> m_pURI;
HTTPVersion m_Version;
nsVoidArray* m_pArray;
// The actual request stream!
nsIBufferInputStream* m_Request;
nsVoidArray* m_pArray;
nsIChannel* m_pTransport;
nsHTTPChannel* m_pConnection;
};

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

@ -421,15 +421,17 @@ nsHTTPResponse::GetContentLength(PRInt32* o_Value) const
}
NS_METHOD
nsHTTPResponse::GetStatus(PRInt32* o_Value) const
nsHTTPResponse::GetStatus(PRUint32* o_Value) const
{
if (o_Value)
*o_Value = -1;
*o_Value = m_Status;
else
return NS_ERROR_NULL_POINTER;
return NS_OK;
}
NS_METHOD
nsHTTPResponse::GetStatusString(const char* *o_String) const
nsHTTPResponse::GetStatusString(char* *o_String) const
{
if (o_String)
*o_String = m_pStatusString;
@ -437,7 +439,7 @@ nsHTTPResponse::GetStatusString(const char* *o_String) const
}
NS_METHOD
nsHTTPResponse::GetServer(const char* *o_String) const
nsHTTPResponse::GetServer(char* *o_String) const
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -153,9 +153,9 @@ public:
// Stuff from nsIHTTPResponse
NS_IMETHOD GetContentLength(PRInt32* o_Value) const;
NS_IMETHOD GetStatus(PRInt32* o_Value) const;
NS_IMETHOD GetStatusString(const char* *o_String) const;
NS_IMETHOD GetServer(const char* *o_String) const;
NS_IMETHOD GetStatus(PRUint32* o_Value) const;
NS_IMETHOD GetStatusString(char* *o_String) const;
NS_IMETHOD GetServer(char* *o_String) const;
// Finally our own methods...