using namespace boost::network::http;
client c;
request req("https://somedomain.com/");
response res = c.get(req);
There's no difference between making an HTTPS or an HTTP request as
far as the interface is concerned. You don't have to worry about that
detail, the library does it for you.
> Assuming that Boost.Asio is used internally, another question would
> be, if it's possible to provide the io_service to be used by the
> client object, but that's not so important.
>
With 0.9.x, yes:
using namespace boost::network::http;
client c(_io_service=my_io_service_instance);
You can find this here:
http://cpp-netlib.github.com/0.9.1/reference_http_client.html#constructors
> Nontheless answering both questions would be a great addition to the
> docs ;-)
>
I wasn't sure that making the URI include whether it's HTTP/HTTPS
wasn't obvious enough.
HTH
--
Dean Michael Berris
Technical Solutions Engineer
Google
Can I make a case for the default behaviour to be inclusion of OpenSSL rather than exclusion? It is reasonably expected that clients of an http library will usually require support of both protocols - http and https. Those who don't have OpenSSL will immediately get compiler errors and those who are looking to optimize or omit SSL support can be directed to the pre processing definition to remove SSL support if it suits the application domain. Doing so will ensure that the common case of a user just wanting a quick and dirty C++ way to be http(s) enabled will have as few surprises as possible. Http and https will "just work" as intended out of the box. If there is support for this, I am willing to write a patch for this. (I'm assuming that it will be trivial but I haven't seen the codebase in quite sometime).
Please let me know your thoughts.
-- Divye
>Can I make a case for the default behaviour to be inclusion of OpenSSL
>rather than exclusion? It is reasonably expected that clients of an http
>library will usually require support of both protocols - http and https.
>Those who don't have OpenSSL will immediately get compiler errors and
>those who are looking to optimize or omit SSL support can be directed
>to the pre processing definition to remove SSL support if it suits the
>application domain. Doing so will ensure that the common case of a user
>just wanting a quick and dirty C++ way to be http(s) enabled will have
>as few surprises as possible. Http and https will "just work" as intended
>out of the box. If there is support for this, I am willing to write a
>patch for this. (I'm assuming that it will be trivial but I haven't
>seen the codebase in quite sometime).
>Please let me know your thoughts.
I strongly disagree. OpenSSL is a huge dependency. OpenSSL itself depends on Perl. What's the benefit in making cpp-netlib dependent on so many third-party packages?
IMO, the simple one-line http GET is what should work out of the box. It requires no dependencies, and that's where just about everybody will start. If that doesn't compile, many people will say "It's too complicated" and walk away.
FWIW, this isn't the first time we've had this idea floated on the list.
Erik
----------------------------------------------------------------------
This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited.
Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law.
The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses.
References to "Sender" are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link:
http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing.
Please see in-lined below.
On Wed, Sep 14, 2011 at 8:16 AM, Nelson, Erik - 2
<erik.l...@bankofamerica.com> wrote:
> Divye Kapoor wrote on Wednesday, September 14, 2011 1:12 AM
>
>>Can I make a case for the default behaviour to be inclusion of OpenSSL
>>rather than exclusion? It is reasonably expected that clients of an http
>>library will usually require support of both protocols - http and https.
>>Those who don't have OpenSSL will immediately get compiler errors and
>>those who are looking to optimize or omit SSL support can be directed
>>to the pre processing definition to remove SSL support if it suits the
>>application domain. Doing so will ensure that the common case of a user
>>just wanting a quick and dirty C++ way to be http(s) enabled will have
>>as few surprises as possible. Http and https will "just work" as intended
>>out of the box. If there is support for this, I am willing to write a
>>patch for this. (I'm assuming that it will be trivial but I haven't
>>seen the codebase in quite sometime).
>>Please let me know your thoughts.
>
There's two pieces to the puzzle here.
When cpp-netlib used to be header-only exclusively, making it depend
on OpenSSL by default is bad. The surprise of not being able to at
least compile when OpenSSL is not present is a killer. Lowering the
cost of using the library by not implicitly depending on OpenSSL is
good thing.
Now though that we're moving away from the header-only model, I would
think that at build time of the external libraries, we should be able
to determine whether OpenSSL is present or not. Making cpp-netlib
explicitly depend on OpenSSL on deployment time is another matter (in
case people want to package cpp-netlib for Windows/Linux/Mac). I would
think though that making OpenSSL a *requirement* is going to be
tricky.
For now I would say we should stick to the status quo until we can
find out an acceptable solution while in the transition from
header-only to non-header-only.
> I strongly disagree. OpenSSL is a huge dependency. OpenSSL itself depends on Perl. What's the benefit in making cpp-netlib dependent on so many third-party packages?
>
> IMO, the simple one-line http GET is what should work out of the box. It requires no dependencies, and that's where just about everybody will start. If that doesn't compile, many people will say "It's too complicated" and walk away.
>
I agree here. Unfortunately though the reality is becoming clear that
as more and more of the web move to an SSL-protected HTTP
implementation, that would mean the likelihood that they will need
HTTPS support out of the box is something that needs to be recognized.
How we're going to solve the problem of usability and making
deployment easier may be a matter outside of just way the code is
written but also how the libraries are packaged.
> FWIW, this isn't the first time we've had this idea floated on the list.
>
Indeed. That being said though that means we may need to address it
one way or another. At this time I'm not ready to give a definitive
answer yet, but I'd like to try out a few things first and see how far
we can get with different potential approaches (even just
theoretically).
Cheers
This is a known issue, and I have this fixed partially in my branch.
I'll prepare a pull request and I forget if I've already done this for
cpp-netlib/cpp-netlib master. If you try with the latest version in
the master branch and let us know if that fixes the issue it would be
greatly appreciated.
Cheers
On Tue, Apr 3, 2012 at 6:57 PM, Jorge García Rodríguez
Ouch. Looks like it's not fixed yet in cpp-netlib/cpp-netlib's master
branch. I'll try and fix this back-porting what I did in
deanberris/cpp-netlib's master just so that we can remove this wart
from 0.9.3 -- and hopefully push 0.9.4 out soonish.
> Thanks for your fast response.
>
You're welcome. Thanks for your report. :)
Hi Jorge,
I've just pushed a fix to the master branch for this failure. This
should fix all short-read related failures with HTTPS.
Can you verify that this has been fixed?
> On Wed, Apr 4, 2012 at 8:17 PM, Jorge García Rodríguez
This is, unfortunately, well-defined behavior. Here are the reasons:
- The simple_wget example assumes that it's using HTTP/1.0 which has
since 0.9.3 been technically demoted (the default is now HTTP/1.1).
- This won't block "forever" as the Google server will terminate the
connection at some point, but thanks to HTTP/1.1 persistent
connections it doesn't close the connection actively, or within a
certain amount of time.
- If you add `<< header("Connection", "close")` to the request object
before calling `client.get(request)` then the Google HTTP server
*should* terminate the connection from their end once the request has
been responded to.
The bug then resides in the example, and not in the implementation.
Just curiously have you tried running the test suite to confirm
whether you're still seeing the issue on your end?
I've fixed this last remaining test failure. I'll now be tagging 0.9.4
and releasing it in the next few minutes.
Glyn, can you help with the announcement for general availability once
this is done?
Thanks in advance.
Cheers
On Tue, Apr 17, 2012 at 5:44 PM, Jorge García Rodríguez
<jorgeg...@gmail.com> wrote:
> The complete tests suite ends properly and without errors, but the test
> http-client_get:
>
> C:\cpp-netlib-build\tests\Release>cpp-netlib-http-client_get_test.exe
> Running 24 test cases...
>
> It doesn't end (at least in 3 hours that I let it running).
>
> I guess it is affected by the same behavior that you mention. This:
>
> http::client::request request("https://www.google.es");
> request << header("Connection", "close");
> http::client client;
>
> http::client::response response = client.get(request);
>
> cout << body(response) << endl;
>
> ends is "short read".
>
> I'm using cpp-netlib-cpp-netlib-0.9.3-48-g792f0d0 with boost 1.47 with
> OpenSSL 1.0.1, every thing compiled with Visual Studio 2010 (x86) in a
> 64bits Windows 7 machine.
>
> Greetings and thanks!
>
> Jorge.-
>
> El lunes, 16 de abril de 2012 04:04:07 UTC+2, Dean Michael Berris escribió:
+cpp-netlibI've fixed this last remaining test failure. I'll now be tagging 0.9.4
and releasing it in the next few minutes.Glyn, can you help with the announcement for general availability once
this is done?Thanks in advance.
Cheers
On Tue, Apr 17, 2012 at 5:44 PM, Jorge García Rodríguez