Click here to Skip to main content
13,002,343 members (77,496 online)
Rate this:
Please Sign up or sign in to vote.
Hi I am new user of Boost
I wanted to connect to a http web site by proxy
and want to download "" this file.
it is telling connected
but not able to download the link above and also not able to maintain the connection.

here is my code.

io_service i; 
tcp::socket t( i ); 
//ssl::context c( i, ssl::context::sslv3_client ); 
//ssl::stream<tcp::socket&> s( t, c ); 
tcp::resolver r( i ); 
tcp::resolver::query q( "", "3128" ); 
t.connect( *r.resolve( q ) ); 
const char request[] = "CONNECT HTTP/1.0\r\n Connection: keep-alive \r\n\r\n"; 
//to keep the conn alive  "Connection: keep-alive" but :( 
boost::asio::write( t, buffer( request, sizeof request - 1 ) ); 
boost::asio::streambuf res; 
boost::asio::read_until( t, res, "\r\n\r\n" ); 
cout << &res; // => "HTTP/1.0 200 Connection established\r\n\r\n"  coming :) 

//now I want download 
const char request1[]= "GET /LICENSE_1_0.txt HTTP/1.0 \r\n  Host:  \r\n Accept: */*\r\n Connection: keep-alive \r\n\r\n" ; 
boost::asio::write( t, buffer( request1, sizeof request1 - 1 ) ); 
boost::asio::read_until( t, res, "\r\n\r\n" ); 
cout << &res;//it is coming into catch block and printing  "Exception: read_unti: end of file"
  catch (std::exception& e) 
    std::cout << "Exception: " << e.what() << "\n"; 
Posted 3-Dec-11 6:40am
Shakti Misra 14-Dec-11 1:16am
What is the exception you are getting?
May be this
will help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170626.1 | Last Updated 3 Dec 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100