From 493dbb7e5b0c23655f3eb694689df215cd2cbdd8 Mon Sep 17 00:00:00 2001 From: "heikki%netscape.com" Date: Tue, 13 Aug 2002 19:25:54 +0000 Subject: [PATCH] Bug 142812, setRequestHeader() should set, not add to, the header. r=timeless, sr=darin. --- extensions/xmlextras/base/src/nsXMLHttpRequest.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index 2ce4ab74309d..64981137700c 100644 --- a/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -1268,9 +1268,17 @@ nsXMLHttpRequest::SetRequestHeader(const char *header, const char *value) nsCOMPtr httpChannel(do_QueryInterface(mChannel)); - if (httpChannel) + if (httpChannel) { + // We need to set, not add to, the header. Using empty value will + // clear existing header. + nsresult rv = httpChannel->SetRequestHeader(nsDependentCString(header), + nsCString()); + if (NS_FAILED(rv)) + return rv; + // Now set it for real return httpChannel->SetRequestHeader(nsDependentCString(header), nsDependentCString(value)); + } return NS_OK; }