HTTP Request/Response Libraries?

This is a discussion on HTTP Request/Response Libraries? within the Networking/Device Communication forums, part of the General Programming Boards category; Are there any free libraries available for performing HTTP requests and responses?...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Location
    Birmingham, UK.
    Posts
    14

    HTTP Request/Response Libraries?

    Are there any free libraries available for performing HTTP requests and responses?

  2. #2
    Registered User
    Join Date
    Dec 2008
    Location
    Birmingham, UK.
    Posts
    14
    Ah I think libcurl might be useful. I only need it to get the content from a page. It's for a data harvester.

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    If you only need source you can save it to a file:
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <windows.h>
    
    #include <urlmon.h>
    
    /* Or link to the library via the means you normally would do */
    #pragma comment( lib, "urlmon.lib" )
    
    int main() {
      char url[] = "http://www.google.com";
      char sourceFile[MAX_PATH];
    
      HRESULT hr = URLDownloadToCacheFile(0, url,
        sourceFile, MAX_PATH, 0, 0);
    
      if ( hr == S_OK ) {
        /* Read the file at sourceFile */
        printf( "Source located at: %s\n", sourceFile );
      }
    
      return 0;
    }
    This works with visual studio. What compiler do you use?
    [edit] Sorry, first code I posted was C++
    Last edited by twomers; 12-24-2008 at 06:44 AM.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Quote Originally Posted by twomers View Post
    If you only need source you can save it to a file:
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <windows.h>
    
    #include <urlmon.h>
    
    /* Or link to the library via the means you normally would do */
    #pragma comment( lib, "urlmon.lib" )
    
    int main() {
      char url[] = "http://www.google.com";
      char sourceFile[MAX_PATH];
    
      HRESULT hr = URLDownloadToCacheFile(0, url,
        sourceFile, MAX_PATH, 0, 0);
    
      if ( hr == S_OK ) {
        /* Read the file at sourceFile */
        printf( "Source located at: %s\n", sourceFile );
      }
    
      return 0;
    }
    This works with visual studio. What compiler do you use?
    [edit] Sorry, first code I posted was C++
    You wouldn't happen to have a Linux equivalent for this would you? That would save me about 3 days of Google searching...
    Fried chicken for everybody!
    -Kernel Sanders

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Sorry. Maybe someone else can help.

    Though libcurl is easy to work with. And if your 'data harvester' needs to get fancier, ie using cookie manipulation, multi threading, etc, it'll be easier to do it with libcurl than other high level functions, I think.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,312
    Moved to Networking/Device Communication forum.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657
    Like jamesjeffery said, libcurl is the way to go. Here's the tutorial.

  8. #8
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > You wouldn't happen to have a Linux equivalent for this would you?
    Sure, either use libcurl as mentioned above or call `wget`

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error stop Http Listener
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 06-04-2008, 03:14 AM
  2. my HTTP request handler code correct?
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 04-25-2008, 05:01 AM
  3. C# HTTP request/response
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 04-02-2008, 07:00 AM
  4. MinGW thread-safe runtime libraries
    By Mario F. in forum C++ Programming
    Replies: 3
    Last Post: 08-21-2006, 09:15 AM
  5. Writing all HTTP requests from a website to a log file
    By goomyman in forum C# Programming
    Replies: 1
    Last Post: 07-29-2005, 10:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21