mshtml: Get rid of handling post data in IPersistMoniker::Load hack.
This commit is contained in:
parent
98fdb660be
commit
13a84dea30
|
@ -39,129 +39,6 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
||||
|
||||
#define USER_AGENT "User-Agent:"
|
||||
#define CONTENT_TYPE "Content-Type:"
|
||||
|
||||
static int fix_headers(char *buf, DWORD post_len)
|
||||
{
|
||||
char *ptr = buf, *ptr2;
|
||||
|
||||
while(*ptr && (ptr[0] != '\r' || ptr[1] != '\n')) {
|
||||
for(ptr2=ptr+1; *ptr2 && (ptr2[0] != '\r' || ptr2[1] != '\n'); ptr2++);
|
||||
|
||||
if(*ptr2)
|
||||
ptr2 += 2;
|
||||
|
||||
if(!strncasecmp(ptr, USER_AGENT, sizeof(USER_AGENT)-1)) {
|
||||
FIXME("Ignoring User-Agent header\n");
|
||||
memmove(ptr, ptr2, strlen(ptr2)+1);
|
||||
}else if(!post_len && !strncasecmp(ptr, CONTENT_TYPE, sizeof(CONTENT_TYPE)-1)) {
|
||||
TRACE("Ignoring Content-Type header\n");
|
||||
memmove(ptr, ptr2, strlen(ptr2)+1);
|
||||
}else {
|
||||
ptr = ptr2;
|
||||
}
|
||||
}
|
||||
|
||||
*ptr = 0;
|
||||
return ptr-buf;
|
||||
}
|
||||
|
||||
static nsIInputStream *get_post_data_stream(IBindCtx *bctx)
|
||||
{
|
||||
nsIInputStream *ret = NULL;
|
||||
IUnknown *unk;
|
||||
IBindStatusCallback *callback;
|
||||
IServiceProvider *service_provider;
|
||||
BINDINFO bindinfo;
|
||||
DWORD bindf = 0;
|
||||
DWORD post_len = 0, headers_len = 0;
|
||||
LPWSTR headers = NULL;
|
||||
WCHAR emptystr[] = {0};
|
||||
char *data;
|
||||
HRESULT hres;
|
||||
|
||||
static WCHAR _BSCB_Holder_[] =
|
||||
{'_','B','S','C','B','_','H','o','l','d','e','r','_',0};
|
||||
|
||||
|
||||
/* FIXME: This should be done in URLMoniker */
|
||||
if(!bctx)
|
||||
return NULL;
|
||||
|
||||
hres = IBindCtx_GetObjectParam(bctx, _BSCB_Holder_, &unk);
|
||||
if(FAILED(hres))
|
||||
return NULL;
|
||||
|
||||
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&callback);
|
||||
if(FAILED(hres)) {
|
||||
IUnknown_Release(unk);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&service_provider);
|
||||
IUnknown_Release(unk);
|
||||
if(SUCCEEDED(hres)) {
|
||||
IHttpNegotiate *http_negotiate;
|
||||
|
||||
hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
|
||||
(void**)&http_negotiate);
|
||||
if(SUCCEEDED(hres)) {
|
||||
hres = IHttpNegotiate_BeginningTransaction(http_negotiate, emptystr,
|
||||
emptystr, 0, &headers);
|
||||
IHttpNegotiate_Release(http_negotiate);
|
||||
|
||||
if(SUCCEEDED(hres) && headers)
|
||||
headers_len = WideCharToMultiByte(CP_ACP, 0, headers, -1, NULL, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
IServiceProvider_Release(service_provider);
|
||||
}
|
||||
|
||||
memset(&bindinfo, 0, sizeof(bindinfo));
|
||||
bindinfo.cbSize = sizeof(bindinfo);
|
||||
|
||||
hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
|
||||
|
||||
if(SUCCEEDED(hres) && bindinfo.dwBindVerb == BINDVERB_POST)
|
||||
post_len = bindinfo.cbstgmedData;
|
||||
|
||||
if(headers_len || post_len) {
|
||||
int len = 0;
|
||||
|
||||
static const char content_length[] = "Content-Length: %u\r\n\r\n";
|
||||
|
||||
data = heap_alloc(headers_len+post_len+sizeof(content_length)+10);
|
||||
|
||||
if(headers_len) {
|
||||
WideCharToMultiByte(CP_ACP, 0, headers, -1, data, headers_len, NULL, NULL);
|
||||
len = fix_headers(data, post_len);
|
||||
if(len >= 2 && (data[len-1] != '\n' || data[len-2] != '\r')) {
|
||||
data[len++] = '\r';
|
||||
data[len++] = '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if(post_len) {
|
||||
sprintf(data+len, content_length, post_len);
|
||||
len += strlen(data+len);
|
||||
|
||||
memcpy(data+len, bindinfo.stgmedData.u.hGlobal, post_len);
|
||||
}
|
||||
|
||||
TRACE("data = %s\n", debugstr_an(data, len+post_len));
|
||||
|
||||
if(len)
|
||||
ret = create_nsstream(data, len+post_len);
|
||||
}
|
||||
|
||||
CoTaskMemFree(headers);
|
||||
ReleaseBindInfo(&bindinfo);
|
||||
IBindStatusCallback_Release(callback);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static BOOL use_gecko_script(LPCWSTR url)
|
||||
{
|
||||
static const WCHAR fileW[] = {'f','i','l','e',':'};
|
||||
|
@ -304,16 +181,10 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
|
|||
push_task(task);
|
||||
|
||||
if(This->nscontainer) {
|
||||
nsIInputStream *post_data_stream = get_post_data_stream(pibc);
|
||||
|
||||
This->nscontainer->bscallback = bscallback;
|
||||
nsres = nsIWebNavigation_LoadURI(This->nscontainer->navigation, url,
|
||||
LOAD_FLAGS_NONE, NULL, post_data_stream, NULL);
|
||||
LOAD_FLAGS_NONE, NULL, NULL, NULL);
|
||||
This->nscontainer->bscallback = NULL;
|
||||
|
||||
if(post_data_stream)
|
||||
nsIInputStream_Release(post_data_stream);
|
||||
|
||||
if(NS_FAILED(nsres)) {
|
||||
WARN("LoadURI failed: %08x\n", nsres);
|
||||
IUnknown_Release((IUnknown*)bscallback);
|
||||
|
|
Loading…
Reference in New Issue