You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Cyrus Adkisson <cy...@gmail.com> on 2013/01/14 19:50:25 UTC

httpcore + ssl... is NIO the only way?

I'm currently using httpcore to access the Twitter api. It's been a
life-saver since Twitter needs RFC 3986 encoding and HttpClient defaults to
(and seems difficult to un-default from) a lower URL encoding (17xx, can't
remember exactly).

Everything is working perfectly at the moment with http, but I really
should be using https. Looking around for an example of HTTPS with
httpcore, all I could find were some examples using the NIO package.

Is NIO the only (or simplest) way to form SSL requests with httpcore?

Cyrus

Re: httpcore + ssl... is NIO the only way?

Posted by Cyrus Adkisson <cy...@gmail.com>.
Very much so. Thank you

On Mon, Jan 14, 2013 at 3:11 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Mon, 2013-01-14 at 13:50 -0500, Cyrus Adkisson wrote:
> > I'm currently using httpcore to access the Twitter api. It's been a
> > life-saver since Twitter needs RFC 3986 encoding and HttpClient defaults
> to
> > (and seems difficult to un-default from) a lower URL encoding (17xx,
> can't
> > remember exactly).
> >
>
> As of version 4.3 HttpClient will also execute requests with
> non-standard request URIs, if that helps.
>
> > Everything is working perfectly at the moment with http, but I really
> > should be using https. Looking around for an example of HTTPS with
> > httpcore, all I could find were some examples using the NIO package.
> >
> > Is NIO the only (or simplest) way to form SSL requests with httpcore?
> >
>
> Absolutely not. Blocking HTTP connections can be bound to any arbitrary
> socket (plain or SSL)
>
> ---
> SSLContext sslcontext = SSLContext.getInstance("TLS");
> sslcontext.init(null, null, null);
> SSLSocketFactory ssf = sslcontext.getSocketFactory();
> Socket socket = ssf.createSocket();
> socket.connect(
>   new InetSocketAddress(host.getHostName(), host.getPort()), 0);
> conn.bind(socket);
> ---
>
> Hope this helps
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: httpcore + ssl... is NIO the only way?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2013-01-14 at 13:50 -0500, Cyrus Adkisson wrote:
> I'm currently using httpcore to access the Twitter api. It's been a
> life-saver since Twitter needs RFC 3986 encoding and HttpClient defaults to
> (and seems difficult to un-default from) a lower URL encoding (17xx, can't
> remember exactly).
> 

As of version 4.3 HttpClient will also execute requests with
non-standard request URIs, if that helps. 

> Everything is working perfectly at the moment with http, but I really
> should be using https. Looking around for an example of HTTPS with
> httpcore, all I could find were some examples using the NIO package.
> 
> Is NIO the only (or simplest) way to form SSL requests with httpcore?
> 

Absolutely not. Blocking HTTP connections can be bound to any arbitrary
socket (plain or SSL)

---
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
SSLSocketFactory ssf = sslcontext.getSocketFactory();
Socket socket = ssf.createSocket();
socket.connect(
  new InetSocketAddress(host.getHostName(), host.getPort()), 0);
conn.bind(socket);
---

Hope this helps

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org