зеркало из https://github.com/mozilla/pjs.git
Fix for NPN_PostURL not always working correctly [like with binary file data] bug 105417 r=av sr=darin
This commit is contained in:
Родитель
41894e82a4
Коммит
4527faeedf
|
@ -163,7 +163,7 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
|
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
|
||||||
PRUint32 aPostDataLen, void *aHeadersData,
|
PRUint32 aPostDataLen, void *aHeadersData,
|
||||||
PRUint32 aHeadersDataLen);
|
PRUint32 aHeadersDataLen, PRBool isFile = PR_FALSE);
|
||||||
|
|
||||||
NS_IMETHOD ShowStatus(const char *aStatusMsg);
|
NS_IMETHOD ShowStatus(const char *aStatusMsg);
|
||||||
|
|
||||||
|
@ -2235,7 +2235,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData,
|
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData,
|
||||||
PRUint32 aHeadersDataLen)
|
PRUint32 aHeadersDataLen, PRBool isFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mOwner,NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(mOwner,NS_ERROR_NULL_POINTER);
|
||||||
NS_ENSURE_TRUE(mContext,NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(mContext,NS_ERROR_NULL_POINTER);
|
||||||
|
@ -2271,9 +2271,28 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
|
||||||
nsCOMPtr<nsISupports> result;
|
nsCOMPtr<nsISupports> result;
|
||||||
nsCOMPtr<nsIInputStream> postDataStream;
|
nsCOMPtr<nsIInputStream> postDataStream;
|
||||||
nsCOMPtr<nsIInputStream> headersDataStream;
|
nsCOMPtr<nsIInputStream> headersDataStream;
|
||||||
|
|
||||||
|
// deal with post data, either in a file or raw data, and any headers
|
||||||
if (aPostData) {
|
if (aPostData) {
|
||||||
rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), PR_FALSE, (const char *) aPostData, 0);
|
if (isFile) {
|
||||||
|
// convert file:///c:/ to c:
|
||||||
|
const char * fileURL = (const char*)aPostData; // default to raw data
|
||||||
|
nsXPIDLCString path;
|
||||||
|
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||||
|
if (NS_SUCCEEDED(aFile->SetURL(fileURL)))
|
||||||
|
if (NS_SUCCEEDED(aFile->GetPath(getter_Copies(path))))
|
||||||
|
fileURL = (const char*)path;
|
||||||
|
|
||||||
|
// use NewPostDataStream only for post data on disk
|
||||||
|
rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), isFile, fileURL, 0);
|
||||||
|
} else {
|
||||||
|
// use NewByteInputStream to handle binary post data, see bug 105417
|
||||||
|
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aPostData, aPostDataLen);
|
||||||
|
if (result)
|
||||||
|
postDataStream = do_QueryInterface(result, &rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aHeadersData) {
|
if (aHeadersData) {
|
||||||
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aHeadersData, aHeadersDataLen);
|
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aHeadersData, aHeadersDataLen);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -163,7 +163,7 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
|
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
|
||||||
PRUint32 aPostDataLen, void *aHeadersData,
|
PRUint32 aPostDataLen, void *aHeadersData,
|
||||||
PRUint32 aHeadersDataLen);
|
PRUint32 aHeadersDataLen, PRBool isFile = PR_FALSE);
|
||||||
|
|
||||||
NS_IMETHOD ShowStatus(const char *aStatusMsg);
|
NS_IMETHOD ShowStatus(const char *aStatusMsg);
|
||||||
|
|
||||||
|
@ -2235,7 +2235,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData,
|
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData,
|
||||||
PRUint32 aHeadersDataLen)
|
PRUint32 aHeadersDataLen, PRBool isFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mOwner,NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(mOwner,NS_ERROR_NULL_POINTER);
|
||||||
NS_ENSURE_TRUE(mContext,NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(mContext,NS_ERROR_NULL_POINTER);
|
||||||
|
@ -2271,9 +2271,28 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
|
||||||
nsCOMPtr<nsISupports> result;
|
nsCOMPtr<nsISupports> result;
|
||||||
nsCOMPtr<nsIInputStream> postDataStream;
|
nsCOMPtr<nsIInputStream> postDataStream;
|
||||||
nsCOMPtr<nsIInputStream> headersDataStream;
|
nsCOMPtr<nsIInputStream> headersDataStream;
|
||||||
|
|
||||||
|
// deal with post data, either in a file or raw data, and any headers
|
||||||
if (aPostData) {
|
if (aPostData) {
|
||||||
rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), PR_FALSE, (const char *) aPostData, 0);
|
if (isFile) {
|
||||||
|
// convert file:///c:/ to c:
|
||||||
|
const char * fileURL = (const char*)aPostData; // default to raw data
|
||||||
|
nsXPIDLCString path;
|
||||||
|
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||||
|
if (NS_SUCCEEDED(aFile->SetURL(fileURL)))
|
||||||
|
if (NS_SUCCEEDED(aFile->GetPath(getter_Copies(path))))
|
||||||
|
fileURL = (const char*)path;
|
||||||
|
|
||||||
|
// use NewPostDataStream only for post data on disk
|
||||||
|
rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), isFile, fileURL, 0);
|
||||||
|
} else {
|
||||||
|
// use NewByteInputStream to handle binary post data, see bug 105417
|
||||||
|
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aPostData, aPostDataLen);
|
||||||
|
if (result)
|
||||||
|
postDataStream = do_QueryInterface(result, &rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aHeadersData) {
|
if (aHeadersData) {
|
||||||
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aHeadersData, aHeadersDataLen);
|
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aHeadersData, aHeadersDataLen);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Netscape Public License
|
|
||||||
* Version 1.1 (the "License"); you may not use this file except in
|
|
||||||
* compliance with the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/NPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is mozilla.org code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Netscape Communications Corporation.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the NPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#ifndef nsIPluginInstanceOwner_h___
|
|
||||||
#define nsIPluginInstanceOwner_h___
|
|
||||||
|
|
||||||
#include "nsISupports.h"
|
|
||||||
#include "nsplugin.h"
|
|
||||||
|
|
||||||
class nsIDocument;
|
|
||||||
|
|
||||||
#define NS_IPLUGININSTANCEOWNER_IID \
|
|
||||||
{ 0x18270870, 0x32f1, 0x11d2, \
|
|
||||||
{ 0xa8, 0x30, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
|
||||||
|
|
||||||
struct nsIPluginInstanceOwner : public nsISupports
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPLUGININSTANCEOWNER_IID)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Let the owner know that an instance has been created
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
SetInstance(nsIPluginInstance *aInstance) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the instance associated with this owner.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
GetInstance(nsIPluginInstance *&aInstance) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a handle to the window structure of the owner.
|
|
||||||
* This pointer cannot be made persistant by the caller.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
GetWindow(nsPluginWindow *&aWindow) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the display mode for the plugin instance.
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
GetMode(nsPluginMode *aMode) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a place for the plugin to live in the owner's
|
|
||||||
* environment. this may or may not create a window
|
|
||||||
* depending on the windowless state of the plugin instance.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
CreateWidget(void) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when there is a valid target so that the proper
|
|
||||||
* frame can be updated with new content. will not be called
|
|
||||||
* with nsnull aTarget.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
GetURL(const char *aURL, const char *aTarget,
|
|
||||||
void *aPostData, PRUint32 aPostDataLen,
|
|
||||||
void *aHeadersData, PRUint32 aHeadersDataLen) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a status message in the host environment.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
ShowStatus(const char *aStatusMsg) = 0;
|
|
||||||
|
|
||||||
NS_IMETHOD
|
|
||||||
ShowStatus(const PRUnichar *aStatusMsg) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the associated document.
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
GetDocument(nsIDocument* *aDocument) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invalidate the rectangle
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
InvalidateRect(nsPluginRect *invalidRect) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invalidate the region
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
InvalidateRegion(nsPluginRegion invalidRegion) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Force a redraw
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
ForceRedraw() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the specified variable
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
GetValue(nsPluginInstancePeerVariable variable, void *value) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -2798,8 +2798,21 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst,
|
||||||
else if (0 == PL_strcmp(target, "_current"))
|
else if (0 == PL_strcmp(target, "_current"))
|
||||||
target = "_self";
|
target = "_self";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure there is "r\n\r\n" before the post data
|
||||||
|
if (!PL_strnstr(postData, "\r\n\r\n", postDataLen))
|
||||||
|
{
|
||||||
|
char *newPostData = nsnull;
|
||||||
|
PRUint32 newPostDataLen = 0;
|
||||||
|
if (NS_SUCCEEDED(FixPostData(postData, postDataLen, &newPostData, &newPostDataLen)))
|
||||||
|
{
|
||||||
|
postData = newPostData;
|
||||||
|
postDataLen = newPostDataLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rv = owner->GetURL(url, target, (void*)postData, postDataLen,
|
rv = owner->GetURL(url, target, (void*)postData, postDataLen,
|
||||||
(void*) postHeaders, postHeadersLength);
|
(void*) postHeaders, postHeadersLength, isFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_RELEASE(peer);
|
NS_RELEASE(peer);
|
||||||
|
@ -5290,30 +5303,22 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
||||||
// In the file case, hand the filename off to NewPostDataStream
|
// In the file case, hand the filename off to NewPostDataStream
|
||||||
if (aIsFile)
|
if (aIsFile)
|
||||||
{
|
{
|
||||||
|
// convert file:///c:/ to c:
|
||||||
nsXPIDLCString filename;
|
nsXPIDLCString filename;
|
||||||
|
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||||
nsCOMPtr<nsIURI> url;
|
if (NS_SUCCEEDED(aFile->SetURL(aPostData)))
|
||||||
NS_NewURI(getter_AddRefs(url), aPostData);
|
if (NS_SUCCEEDED(aFile->GetPath(getter_Copies(filename)))) {
|
||||||
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(url));
|
|
||||||
if (fileURL) {
|
|
||||||
nsCOMPtr<nsIFile> file;
|
|
||||||
fileURL->GetFile(getter_AddRefs(file));
|
|
||||||
nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(file));
|
|
||||||
if (localFile) {
|
|
||||||
localFile->GetPath(getter_Copies(filename));
|
|
||||||
|
|
||||||
// tell the listener about it so it will delete the file later
|
// tell the listener about it so it will delete the file later
|
||||||
listenerPeer->SetLocalFile(filename);
|
listenerPeer->SetLocalFile(filename);
|
||||||
|
// use NewPostDataStream only for post data on disk
|
||||||
NS_NewPostDataStream(getter_AddRefs(postDataStream), aIsFile, filename, 0);
|
NS_NewPostDataStream(getter_AddRefs(postDataStream), aIsFile, filename, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// In the string case, we create a string buffer stream
|
// In the string case, we create a string buffer stream
|
||||||
//Make sure there is "r\n\r\n" before the post data
|
// Make sure there is "r\n\r\n" before the post data
|
||||||
if (!PL_strstr(aPostData, "\r\n\r\n"))
|
if (!PL_strnstr(aPostData, "\r\n\r\n", aPostDataLen))
|
||||||
{
|
{
|
||||||
if (NS_SUCCEEDED(FixPostData(aPostData, aPostDataLen, &newPostData, &newPostDataLen)))
|
if (NS_SUCCEEDED(FixPostData(aPostData, aPostDataLen, &newPostData, &newPostDataLen)))
|
||||||
{
|
{
|
||||||
|
@ -5321,8 +5326,13 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
||||||
aPostDataLen = newPostDataLen;
|
aPostDataLen = newPostDataLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aPostData)
|
if (aPostData) {
|
||||||
NS_NewPostDataStream(getter_AddRefs(postDataStream), aIsFile, aPostData, 0);
|
nsCOMPtr<nsISupports> result;
|
||||||
|
// use NewByteInputStream to handle binary post data, see bug 105417
|
||||||
|
rv = NS_NewByteInputStream(getter_AddRefs(result), aPostData, aPostDataLen);
|
||||||
|
if (result)
|
||||||
|
postDataStream = do_QueryInterface(result, &rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!postDataStream)
|
if (!postDataStream)
|
||||||
|
@ -5385,7 +5395,7 @@ nsPluginHostImpl::FixPostData(const char *inPostData, PRUint32 inPostDataLen,
|
||||||
}
|
}
|
||||||
nsCRT::memset(newBuf, 0, inPostDataLen + 4);
|
nsCRT::memset(newBuf, 0, inPostDataLen + 4);
|
||||||
|
|
||||||
if (!(crlf = PL_strstr(postData, "\r\n\n"))) {
|
if (!(crlf = PL_strnstr(postData, "\r\n\n", inPostDataLen))) {
|
||||||
delete [] newBuf;
|
delete [] newBuf;
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,7 @@ private:
|
||||||
* character after the last header. It will then create a new buffer
|
* character after the last header. It will then create a new buffer
|
||||||
* with the existing headers, a correct "\r\n\r\n", then the post data.
|
* with the existing headers, a correct "\r\n\r\n", then the post data.
|
||||||
* If no "\r\n" is found, the data does not contain headers, and a simple
|
* If no "\r\n" is found, the data does not contain headers, and a simple
|
||||||
* "\r\n\r\n" is prepended to the buffer.
|
* "\r\n\r\n" is prepended to the buffer. See bug 60228 for more info.
|
||||||
* @param inPostData, the post data from NewPluginURLStream
|
* @param inPostData, the post data from NewPluginURLStream
|
||||||
* @param the length of inPostData
|
* @param the length of inPostData
|
||||||
* @param outPostData the buffer which must be freed with delete [].
|
* @param outPostData the buffer which must be freed with delete [].
|
||||||
|
|
|
@ -124,7 +124,8 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetURL(const char *aURL, const char *aTarget,
|
NS_IMETHOD GetURL(const char *aURL, const char *aTarget,
|
||||||
void *aPostData, PRUint32 aPostDataLen,
|
void *aPostData, PRUint32 aPostDataLen,
|
||||||
void *aHeadersData, PRUint32 aHeadersDataLen);
|
void *aHeadersData, PRUint32 aHeadersDataLen,
|
||||||
|
PRBool isFile = PR_FALSE);
|
||||||
|
|
||||||
NS_IMETHOD ShowStatus(const char *aStatusMsg);
|
NS_IMETHOD ShowStatus(const char *aStatusMsg);
|
||||||
|
|
||||||
|
@ -1032,8 +1033,8 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData,
|
NS_IMETHODIMP pluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen, void *aHeadersData,
|
||||||
PRUint32 aHeadersDataLen)
|
PRUint32 aHeadersDataLen, PRBool isFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mViewer,NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(mViewer,NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
|
@ -1057,13 +1058,28 @@ NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarge
|
||||||
nsCOMPtr<nsISupports> result;
|
nsCOMPtr<nsISupports> result;
|
||||||
nsCOMPtr<nsIInputStream> postDataStream;
|
nsCOMPtr<nsIInputStream> postDataStream;
|
||||||
nsCOMPtr<nsIInputStream> headersDataStream;
|
nsCOMPtr<nsIInputStream> headersDataStream;
|
||||||
|
|
||||||
|
// deal with post data, either in a file or raw data, and any headers
|
||||||
if (aPostData) {
|
if (aPostData) {
|
||||||
if (PL_strncasecmp((const char*)aPostData, "file:///", 8) == 0) {
|
if (isFile) {
|
||||||
const char *fileURL = (const char*)aPostData + 8 ;
|
// convert file:///c:/ to c:
|
||||||
rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), PR_TRUE, fileURL, 0);
|
const char * fileURL = (const char*)aPostData; // default to raw data
|
||||||
} else
|
nsXPIDLCString path;
|
||||||
rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), PR_FALSE, (const char *) aPostData, 0);
|
nsCOMPtr<nsILocalFile> aFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||||
|
if (NS_SUCCEEDED(aFile->SetURL(fileURL)))
|
||||||
|
if (NS_SUCCEEDED(aFile->GetPath(getter_Copies(path))))
|
||||||
|
fileURL = (const char*)path;
|
||||||
|
|
||||||
|
// use NewPostDataStream only for post data on disk
|
||||||
|
rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), isFile, fileURL, 0);
|
||||||
|
} else {
|
||||||
|
// use NewByteInputStream to handle binary post data, see bug 105417
|
||||||
|
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aPostData, aPostDataLen);
|
||||||
|
if (result)
|
||||||
|
postDataStream = do_QueryInterface(result, &rv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aHeadersData) {
|
if (aHeadersData) {
|
||||||
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aHeadersData, aHeadersDataLen);
|
rv = NS_NewByteInputStream(getter_AddRefs(result), (const char *) aHeadersData, aHeadersDataLen);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче