diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 7038c703e4d..6d8e1546bfc 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -165,6 +165,7 @@ typedef struct { nsLoadFlags load_flags; nsIURI *original_uri; char *content; + char *charset; } nsChannel; typedef struct { diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index f9525e7be1f..a30df13eff5 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -37,6 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); #define CONTENT_LENGTH "Content-Length" +#define UTF16_STR "utf-16" #define NSINSTREAM(x) ((nsIInputStream*) &(x)->lpInputStreamVtbl) @@ -399,31 +400,37 @@ static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *if TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed); if(This->nslistener) { - if(!This->nsstream) { + if(!This->nsstream) This->nsstream = create_nsprotocol_stream(pstgmed->u.pstm); - nsres = nsIStreamListener_OnStartRequest(This->nslistener, - (nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext); - if(NS_FAILED(nsres)) - FIXME("OnStartRequest failed: %08x\n", nsres); - } - do { hres = IStream_Read(pstgmed->u.pstm, This->nsstream->buf, sizeof(This->nsstream->buf), &This->nsstream->buf_size); if(!This->nsstream->buf_size) break; + if(!This->readed && This->nsstream->buf_size >= 2 && *(WORD*)This->nsstream->buf == 0xfeff) { + This->nschannel->charset = mshtml_alloc(sizeof(UTF16_STR)); + memcpy(This->nschannel->charset, UTF16_STR, sizeof(UTF16_STR)); + } + + if(!This->readed) { + nsres = nsIStreamListener_OnStartRequest(This->nslistener, + (nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext); + if(NS_FAILED(nsres)) + FIXME("OnStartRequest failed: %08x\n", nsres); + } + + This->readed += This->nsstream->buf_size; + nsres = nsIStreamListener_OnDataAvailable(This->nslistener, (nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext, NSINSTREAM(This->nsstream), This->readed, This->nsstream->buf_size); if(NS_FAILED(nsres)) - FIXME("OnDataAvailable failed: %08x\n", nsres); + ERR("OnDataAvailable failed: %08x\n", nsres); if(This->nsstream->buf_size) FIXME("buffer is not empty!\n"); - - This->readed += This->nsstream->buf_size; }while(hres == S_OK); }else { BYTE buf[1024]; diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index 06bad648540..e3eba43b058 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -221,6 +221,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface) if(This->original_uri) nsIURI_Release(This->original_uri); mshtml_free(This->content); + mshtml_free(This->charset); mshtml_free(This); } @@ -512,11 +513,20 @@ static nsresult NSAPI nsChannel_GetContentCharset(nsIHttpChannel *iface, TRACE("(%p)->(%p)\n", This, aContentCharset); - if(This->channel) - return nsIChannel_GetContentCharset(This->channel, aContentCharset); + if(This->charset) { + nsACString_SetData(aContentCharset, This->charset); + return NS_OK; + } - FIXME("default action not implemented\n"); - return NS_ERROR_NOT_IMPLEMENTED; + if(This->channel) { + nsresult nsres = nsIChannel_GetContentCharset(This->channel, aContentCharset); + const char *ch; + nsACString_GetData(aContentCharset, &ch, NULL); + return nsres; + } + + nsACString_SetData(aContentCharset, ""); + return NS_OK; } static nsresult NSAPI nsChannel_SetContentCharset(nsIHttpChannel *iface, @@ -1871,6 +1881,7 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI ret->notif_callback = NULL; ret->load_flags = 0; ret->content = NULL; + ret->charset = NULL; nsIURI_AddRef(aURI); ret->original_uri = aURI;