Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Invalid Syntax

78 views
Skip to first unread message

Peter Carlson

unread,
Feb 22, 2005, 2:05:00 AM2/22/05
to
ok, I have to resurrect this issue. I am using URLDownloadToFile to DL
install files. The process is simple, connect to the server, retrieve a
list of files, then retrieve each file in the list. Certainly not rocket
science. Here are the
IBindStatusCallback interfaces:
STDMETHOD(OnProgress)(/* [in] */ ULONG ulProgress, /* [in] */ ULONG
ulProgressMax, /* [in] */ ULONG ulStatusCode, /* [in] */ LPCWSTR
wszStatusText);
STDMETHOD(OnStartBinding)(/* [in] */ DWORD dwReserved,/* [in] */ IBinding
__RPC_FAR *pib)
{ return S_OK; }
STDMETHOD(OnStopBinding)(/* [in] */ HRESULT hresult, /* [unique][in] */
LPCWSTR szError)
{ return S_OK; }
STDMETHOD(GetBindInfo)(/* [out] */ DWORD __RPC_FAR *grfBINDF, /*
[unique][out][in] */ BINDINFO __RPC_FAR *pbindinfo)
{
if (!grfBINDF || !pbindinfo) return E_POINTER;
*grfBINDF |= BINDF_RESYNCHRONIZE | BINDF_GETNEWESTVERSION |
BINDF_PRAGMA_NO_CACHE ;
ULONG cbSize = pbindinfo->cbSize;
ZeroMemory(pbindinfo, cbSize);
pbindinfo->cbSize = cbSize;
return S_OK;
}
STDMETHOD(GetPriority)(/* [out] */ LONG __RPC_FAR *pnPriority)
{ return E_NOTIMPL; }
STDMETHOD(OnLowResource)(/* [in] */ DWORD reserved)
{ return E_NOTIMPL; }
STDMETHOD(OnDataAvailable)(/* [in] */ DWORD grfBSCF, /* [in] */ DWORD
dwSize, /* [in] */ FORMATETC __RPC_FAR *pformatetc, /* [in] */ STGMEDIUM
__RPC_FAR *pstgmed)
{ return E_NOTIMPL; }
STDMETHOD(OnObjectAvailable)(/* [in] */ REFIID riid, /* [iid_is][in] */
IUnknown __RPC_FAR *punk)
{ return E_NOTIMPL; }
STDMETHOD_(ULONG,AddRef)()
{ return 0; }
STDMETHOD_(ULONG,Release)()
{ return 0; }
STDMETHOD(QueryInterface)( /* [in] */ REFIID riid, /* [iid_is][out] */ void
__RPC_FAR *__RPC_FAR *ppvObject)
{ return E_NOTIMPL; }

And here is the main logic loop:
CString strSrc("http://download.howudodat.com/chatterbox/download/client/");
strSrc << csFile << ".ggz";
HRESULT hr = URLDownloadToFile ( NULL, strSrc, strDestZ, 0, this );
if ( SUCCEEDED(hr) ) {
// decompress it
}
else
FormatMessage(...)

URLDownloadToFile returns 800401E4 - Invalid Syntax....I'm really stumped on
this one! The crazy thing is that sometimes it works and sometimes it
doesn't...right now it's not working again so I can try and troubleshoot it.

Peter


jeff

unread,
Feb 23, 2005, 10:43:12 AM2/23/05
to
I have this problem too. Finally, I don't use URLDownloadToFile but low
level InternetOpenRequest etc API.

"Peter Carlson" <peter@__N.O.S.P.A.M__howudodat.com> wrote in message
news:efwUVzKG...@TK2MSFTNGP09.phx.gbl...

Peter Carlson

unread,
Feb 23, 2005, 2:07:27 PM2/23/05
to
Well I guess I'll have to reply to my own post. After much research and a
lot of speculation we have identified the problem and a work around,
although not a fix.

The problem has to do with the fact that the file is a gzip file and
urlmon.dll (or some other system dll) is trying to decompress the file. #1
I dont want it to do that and I cant find a way to turn that feature off.
However somewhere along the line this feature got SERIOUSLY BROKE in MS
libraries. Go figure huh! The end result is an impossible to troublshoot
undocumented "Invalid Syntax" error message. It does not occur on all
systems, but somewhere in all the web and google searches, it's related to a
patch, I dont remember the number and now I really dont care.

Workaround, when we build the gzip file we swap the first two bytes of the
resulting file so the web server and browser wont recognize it as a gzip
file. Voila, no more Invalid Syntax errors.

So much for MS QA department...oh never mind that's right MS uses their
customers and poor sap programmers like us to QA....Sorry I forgot.

Peter

"Peter Carlson" <peter@__N.O.S.P.A.M__howudodat.com> wrote in message
news:efwUVzKG...@TK2MSFTNGP09.phx.gbl...

Igor Tandetnik

unread,
Feb 23, 2005, 2:52:14 PM2/23/05
to
"Peter Carlson" <peter@__N.O.S.P.A.M__howudodat.com> wrote in message
news:%23Uccxrd...@TK2MSFTNGP15.phx.gbl

> The problem has to do with the fact that the file is a gzip file and
> urlmon.dll (or some other system dll) is trying to decompress the
> file. #1 I dont want it to do that and I cant find a way to turn
> that feature off.

There's none as far as I know. You can drop down to WinInet level -
WinInet does not decode gzip-encoded data, it gives you the content as
served.

However somewhere along the line this feature got
> SERIOUSLY BROKE in MS libraries. Go figure huh! The end result is
> an impossible to troublshoot undocumented "Invalid Syntax" error
> message. It does not occur on all systems, but somewhere in all the
> web and google searches, it's related to a patch, I dont remember the
> number and now I really dont care.

Yes, I had this problem with gzip - at some point, it just broke. After
a lot of research, it turned out that gzip is broken whenever you use
push mode (which is the only mode supported by URLDownloadToFile). Gzip
still works if you use pull mode (see BINDF_PULLDATA), either with
URLOpenPullStream or just using URL Moniker directly
(IMoniker::BindToStorage).

Pull mode is harder to implement. It's always asynchronous, and you have
to have IBindStatusCallback implementation doing real work. However, it
is much more reliable in my experience. MSHTML uses pull mode
internally, so it probably gets a lot of testing at MS.

This was a couple of years ago, and I'm using pull mode exclusively ever
since, that's probably why your problem did not ring a bell. I should
have suspected gzip from the beginning. Sorry for making you do all this
work, while sitting on the answer the whole time.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Peter Carlson

unread,
Feb 23, 2005, 3:59:48 PM2/23/05
to
No apology needed. You have answered more questions than I have :) It
probably goes unsaid too often, but thanks for all your answers.

Now on to the other bugs I have :)

Peter

0 new messages