Discussion:
CInternetSession::OpenURL
(too old to reply)
Jeff
2008-05-17 12:09:50 UTC
Permalink
Hi

I have very little experience of Http programming and wondered if anyone
could advise me about what happens and when it happens behind the scenes
when I use CInternetSession::OpenUrl. Specifically, I'm wondering about when
bytes are actually available for reading. The background is that I want to
download and display a progressive jpeg. I'm using a file pointer obtained
with the following code:-

iSession = new CInternetSession (_T("Zoom Viewer/1.0"), 1,
PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, INTERNET_FLAG_DONT_CACHE);

iStream = iSession->OpenURL(urlName, 1, INTERNET_FLAG_TRANSFER_BINARY, NULL,
0);

I'd like to begin displaying the progressive jpeg as soon as the bytes
arrive, however I'm not sure if the mechanism I'm using actually buffers the
entire Url before I get the first byte with an iStream->Read(....). If it
does then I might as well read the whole jpeg and be done with it.

The other question I have concerns doing an iStream->Seek(..) followed by an
iStream->Read(...). In this case the Url must surely be downloaded entirely
(or at least as far as the Seek) ??

Is there any mechanism for getting specific bytes from a Url without
customised server side code? And what would be the usual mechanism for
displaying progressive jpegs?

Thanks a lot

Jeff
Volodymyr M. Shcherbyna
2008-05-19 09:16:23 UTC
Permalink
What do you mean under "I want to download and display a progressive jpeg".
Does it means that you want to dipsplay a progress bar which indicates
download progress?
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by Jeff
Hi
I have very little experience of Http programming and wondered if anyone
could advise me about what happens and when it happens behind the scenes
when I use CInternetSession::OpenUrl. Specifically, I'm wondering about
when bytes are actually available for reading. The background is that I
want to download and display a progressive jpeg. I'm using a file pointer
obtained with the following code:-
iSession = new CInternetSession (_T("Zoom Viewer/1.0"), 1,
PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, INTERNET_FLAG_DONT_CACHE);
iStream = iSession->OpenURL(urlName, 1, INTERNET_FLAG_TRANSFER_BINARY,
NULL, 0);
I'd like to begin displaying the progressive jpeg as soon as the bytes
arrive, however I'm not sure if the mechanism I'm using actually buffers
the entire Url before I get the first byte with an iStream->Read(....). If
it does then I might as well read the whole jpeg and be done with it.
The other question I have concerns doing an iStream->Seek(..) followed by
an iStream->Read(...). In this case the Url must surely be downloaded
entirely (or at least as far as the Seek) ??
Is there any mechanism for getting specific bytes from a Url without
customised server side code? And what would be the usual mechanism for
displaying progressive jpegs?
Thanks a lot
Jeff
Jeff
2008-05-19 11:17:07 UTC
Permalink
Post by Volodymyr M. Shcherbyna
What do you mean under "I want to download and display a progressive
jpeg". Does it means that you want to dipsplay a progress bar which
indicates download progress?
--
Hi, thanks for the response.

No, I'm not interested in displaying a progress bar, I just want to display
the different stages of the progressive jpeg as soon as they arrive.

But if the operation of the CInternetSession::OpenURL involves downloading
the entire URL before any bytes are available to the Read(..) operation then
there is no point in displaying a partial quality jpeg - better to just
display the entire full quality jpeg.

I'm hoping that the Read(..) operation will return as soon as the requested
bytes have been downloaded to my machine from the server. What worries me is
that this object also provides a Seek(..) operation and the only way I can
see for that to work is if the entire URL is first downloaded into a local
buffer.

Thanks again
Jeff
Volodymyr M. Shcherbyna
2008-05-19 15:29:19 UTC
Permalink
You can issue a GET request and read data chunk by chunk once it is
arriving.

This will allow you to display the image chunk by chunk while it is
downloading. There are many examples in the internet on how to issue a GET
request and read the data. You may search in the internet, or take a look at
one of my examples, which I did in the past. Please take into account, that
the example is using WinHTTP, and not WinInet, but I think this is plus,
because WinHTTP is more advanced version of WinInet. Example can be
downloaded here:
http://msmvps.com/blogs/v_scherbina/pages/winhttp-amp-wininet-examples.aspx
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by Jeff
Post by Volodymyr M. Shcherbyna
What do you mean under "I want to download and display a progressive
jpeg". Does it means that you want to dipsplay a progress bar which
indicates download progress?
--
Hi, thanks for the response.
No, I'm not interested in displaying a progress bar, I just want to
display the different stages of the progressive jpeg as soon as they
arrive.
But if the operation of the CInternetSession::OpenURL involves downloading
the entire URL before any bytes are available to the Read(..) operation
then there is no point in displaying a partial quality jpeg - better to
just display the entire full quality jpeg.
I'm hoping that the Read(..) operation will return as soon as the
requested bytes have been downloaded to my machine from the server. What
worries me is that this object also provides a Seek(..) operation and the
only way I can see for that to work is if the entire URL is first
downloaded into a local buffer.
Thanks again
Jeff
Jeff
2008-05-19 20:45:02 UTC
Permalink
Post by Volodymyr M. Shcherbyna
You can issue a GET request and read data chunk by chunk once it is
arriving.
This will allow you to display the image chunk by chunk while it is
downloading. There are many examples in the internet on how to issue a GET
request and read the data. You may search in the internet, or take a look
at one of my examples, which I did in the past. Please take into account,
that the example is using WinHTTP, and not WinInet, but I think this is
plus, because WinHTTP is more advanced version of WinInet. Example can be
http://msmvps.com/blogs/v_scherbina/pages/winhttp-amp-wininet-examples.aspx
--
Thanks a million Volodymyr - that looks just the job!

Jeff
Jeff
2008-05-22 20:26:42 UTC
Permalink
Post by Volodymyr M. Shcherbyna
You can issue a GET request and read data chunk by chunk once it is
arriving.
This will allow you to display the image chunk by chunk while it is
downloading. There are many examples in the internet on how to issue a GET
request and read the data. You may search in the internet, or take a look
at one of my examples, which I did in the past. Please take into account,
that the example is using WinHTTP, and not WinInet, but I think this is
plus, because WinHTTP is more advanced version of WinInet. Example can be
http://msmvps.com/blogs/v_scherbina/pages/winhttp-amp-wininet-examples.aspx
Hello again

I included something similar to your example in a small activeX I'm
developing and it works fine.
If I embed this activeX into an internet browser such as IE what can I do to
ensure that the http requests are fed by the Browser's cache rather than the
original server. Or does this come free with WinHTTP?

Thanks again.
Jeff
Volodymyr M. Shcherbyna
2008-06-03 13:59:49 UTC
Permalink
Hello,

Sorry for a delayed answer. Ironically, IE7 uses WinInet and WinHTTP (you
can check this by loading the IE7 into debuger, such as WinDbg or OllyDbg,
and looking at list of loaded modules), so I don't think your WinHTTP driven
application will be able to use the whole IE cache.
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by Jeff
Hello again
I included something similar to your example in a small activeX I'm
developing and it works fine.
If I embed this activeX into an internet browser such as IE what can I do
to ensure that the http requests are fed by the Browser's cache rather
than the original server. Or does this come free with WinHTTP?
Thanks again.
Jeff
Loading...