Jacek Caban : mshtml: Added support for custom post data type.
Alexandre Julliard
julliard at winehq.org
Wed Aug 4 12:27:22 CDT 2010
Module: wine
Branch: master
Commit: 22679a2419597fd65de45a3b0c4c132623bf2a48
URL: http://source.winehq.org/git/wine.git/?a=commit;h=22679a2419597fd65de45a3b0c4c132623bf2a48
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Aug 3 21:40:56 2010 +0200
mshtml: Added support for custom post data type.
---
dlls/mshtml/mshtml_private.h | 1 +
dlls/mshtml/navigate.c | 71 +++++++++++++++++++++++++++++++----------
dlls/mshtml/nsio.c | 24 +++++++++++---
3 files changed, 73 insertions(+), 23 deletions(-)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 1e7bac8..2db2410 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -462,6 +462,7 @@ typedef struct {
nsWineURI *uri;
nsIInputStream *post_data_stream;
+ BOOL parse_stream;
nsILoadGroup *load_group;
nsIInterfaceRequestor *notif_callback;
nsISupports *owner;
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index 239fbea..5cd63c1 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2007 Jacek Caban for CodeWeavers
+ * Copyright 2006-2010 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -679,20 +679,48 @@ static HRESULT parse_headers(const WCHAR *headers, struct list *headers_list)
return S_OK;
}
+static HRESULT read_post_data_stream(nsIInputStream *stream, HGLOBAL *post_data,
+ ULONG *post_data_len)
+{
+ PRUint32 data_len = 0, available = 0;
+ char *data;
+ nsresult nsres;
+
+ nsres = nsIInputStream_Available(stream, &available);
+ if(NS_FAILED(nsres))
+ return E_FAIL;
+
+ data = GlobalAlloc(0, available+1);
+ if(!data)
+ return E_OUTOFMEMORY;
+
+ nsres = nsIInputStream_Read(stream, data, available, &data_len);
+ if(NS_FAILED(nsres)) {
+ GlobalFree(data);
+ return E_FAIL;
+ }
+
+ data[data_len] = 0;
+ *post_data = data;
+ *post_data_len = data_len;
+ return S_OK;
+}
+
static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_ret,
HGLOBAL *post_data_ret, ULONG *post_data_len_ret)
{
- PRUint32 post_data_len = 0, available = 0;
+ ULONG post_data_len;
HGLOBAL post_data = NULL;
LPWSTR headers = NULL;
DWORD headers_len = 0, len;
const char *ptr, *ptr2, *post_data_end;
-
- nsIInputStream_Available(post_data_stream, &available);
- post_data = GlobalAlloc(0, available+1);
- nsIInputStream_Read(post_data_stream, post_data, available, &post_data_len);
+ HRESULT hres;
- TRACE("post_data = %s\n", debugstr_an(post_data, post_data_len));
+ hres = read_post_data_stream(post_data_stream, &post_data, &post_data_len);
+ if(FAILED(hres)) {
+ FIXME("read_post_data_stream failed: %08x\n", hres);
+ return;
+ }
ptr = ptr2 = post_data;
post_data_end = (const char*)post_data+post_data_len;
@@ -1088,20 +1116,27 @@ static HRESULT nsChannelBSC_start_binding(BSCallback *bsc)
static HRESULT nsChannelBSC_init_bindinfo(BSCallback *bsc)
{
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
+ HRESULT hres;
if(This->nschannel && This->nschannel->post_data_stream) {
- WCHAR *headers;
- HRESULT hres;
+ if(This->nschannel->parse_stream) {
+ WCHAR *headers;
- parse_post_data(This->nschannel->post_data_stream, &headers, &This->bsc.post_data, &This->bsc.post_data_len);
+ parse_post_data(This->nschannel->post_data_stream, &headers,
+ &This->bsc.post_data, &This->bsc.post_data_len);
- TRACE("headers = %s post_data = %s\n", debugstr_w(headers),
- debugstr_an(This->bsc.post_data, This->bsc.post_data_len));
+ hres = parse_headers(headers, &This->nschannel->request_headers);
+ heap_free(headers);
+ if(FAILED(hres))
+ return hres;
+ }else {
+ hres = read_post_data_stream(This->nschannel->post_data_stream,
+ &This->bsc.post_data, &This->bsc.post_data_len);
+ if(FAILED(hres))
+ return hres;
+ }
- hres = parse_headers(headers, &This->nschannel->request_headers);
- heap_free(headers);
- if(FAILED(hres))
- return hres;
+ TRACE("post_data = %s\n", debugstr_an(This->bsc.post_data, This->bsc.post_data_len));
}
return S_OK;
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index 13dbc44..d288a6b 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -1323,17 +1323,31 @@ static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
nsChannel *This = NSUPCHANNEL_THIS(iface);
const char *content_type;
- TRACE("(%p)->(%p %s %d)\n", This, aStream, debugstr_nsacstr(aContentType), aContentLength);
+ static const WCHAR content_typeW[] =
+ {'C','o','n','t','e','n','t','-','T','y','p','e',0};
- if(This->post_data_stream)
- nsIInputStream_Release(This->post_data_stream);
+ TRACE("(%p)->(%p %s %d)\n", This, aStream, debugstr_nsacstr(aContentType), aContentLength);
+ This->parse_stream = TRUE;
if(aContentType) {
nsACString_GetData(aContentType, &content_type);
- if(*content_type)
- FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type));
+ if(*content_type) {
+ WCHAR *ct;
+
+ ct = heap_strdupAtoW(content_type);
+ if(!ct)
+ return NS_ERROR_UNEXPECTED;
+
+ set_http_header(&This->request_headers, content_typeW,
+ sizeof(content_typeW)/sizeof(WCHAR), ct, strlenW(ct));
+ heap_free(ct);
+ This->parse_stream = FALSE;
+ }
}
+ if(This->post_data_stream)
+ nsIInputStream_Release(This->post_data_stream);
+
if(aContentLength != -1)
FIXME("Unsupported acontentLength = %d\n", aContentLength);
More information about the wine-cvs
mailing list