CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Location
    Philadelphia, USA
    Posts
    195

    CHttpConnection and downloading images

    I am using the CHttpconnection and CInternetfile classes, and am successfully able to retrieve web pages and also download images. However, here is my problem:

    Some web sites make it so that if you type in the url like http://lala.com/image.gif they will redirect you to their homepage instead of just loading the image by itself. A security feature I suppose. In my code, I parse a web page to grab any image links, and then individually attempt to access each image link, so you can see how the above rule is a problem for me.

    My questions is, Internet Explorer is able to get around this somehow. Since IE shows you a web page and loads all the images in it too. So how does IE get the images without loading a seperate url for each image, and how can I get around that security feature described above if I am using CHttpConnection?

    Easy Internet Software @
    http://www.DummySoftware.com
    ============================
    Tired of popup windows while you surf the web?
    Get PopupDummy! http://www.popupdummy.com

  2. #2
    Join Date
    Apr 2001
    Location
    South Africa
    Posts
    11

    Re: CHttpConnection and downloading images

    An idea would be to look at the HTTP specification to see if there are different requests to retrieve content on a page than to retrieve the page itself.

    Martin Lippert
    http://www.silhouette.co.za

  3. #3
    Join Date
    Sep 1999
    Location
    Philadelphia, USA
    Posts
    195

    Re: CHttpConnection and downloading images

    Hey, good idea. I looked up the protocol details and there is an optional field in the header like this:

    Referer: http://www.w3.org/hypertext/DataSources/Overview.html

    Which looks like what I need. You have to let the server know you are downloading the images from viewing its html page. I did not have that field in my header so the servers would assume I was blindly trying to access an image. Thanks.


    Easy Internet Software @
    http://www.DummySoftware.com
    ============================
    Tired of popup windows while you surf the web?
    Get PopupDummy! http://www.popupdummy.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured