|
15 | 15 |
|
16 | 16 | import static com.ning.http.util.MiscUtil.isNonEmpty;
|
17 | 17 |
|
| 18 | +import com.ning.http.client.AsyncHttpClient; |
18 | 19 | import com.ning.org.jboss.netty.handler.codec.http.CookieDecoder;
|
19 | 20 | import com.ning.http.client.AsyncHandler;
|
20 | 21 | import com.ning.http.client.AsyncHttpClientConfig;
|
|
127 | 128 | import java.net.URISyntaxException;
|
128 | 129 | import java.net.URLEncoder;
|
129 | 130 | import java.security.NoSuchAlgorithmException;
|
| 131 | +import java.security.SecureRandom; |
130 | 132 | import java.util.Collection;
|
131 | 133 | import java.util.HashMap;
|
132 | 134 | import java.util.List;
|
@@ -889,9 +891,9 @@ private boolean sendAsGrizzlyRequest(final Request request,
|
889 | 891 | requestPacket = builder.build();
|
890 | 892 | }
|
891 | 893 | requestPacket.setSecure(secure);
|
892 |
| - if (secure) { |
893 |
| - ctx.notifyDownstream(new SwitchingSSLFilter.SSLSwitchingEvent(true, ctx.getConnection())); |
894 |
| - } |
| 894 | + |
| 895 | + ctx.notifyDownstream(new SwitchingSSLFilter.SSLSwitchingEvent(secure, ctx.getConnection())); |
| 896 | + |
895 | 897 | if (!useProxy && !httpCtx.isWSRequest) {
|
896 | 898 | addQueryString(request, requestPacket);
|
897 | 899 | }
|
@@ -2839,7 +2841,35 @@ public int hashCode() {
|
2839 | 2841 | return result;
|
2840 | 2842 | }
|
2841 | 2843 | } // END AHCWebSocketListenerAdapter
|
2842 |
| - |
| 2844 | + |
| 2845 | + |
| 2846 | + public static void main(String[] args) { |
| 2847 | + SecureRandom secureRandom = new SecureRandom(); |
| 2848 | + SSLContext sslContext = null; |
| 2849 | + try { |
| 2850 | + sslContext = SSLContext.getInstance("TLS"); |
| 2851 | + sslContext.init(null, null, secureRandom); |
| 2852 | + } catch (Exception e) { |
| 2853 | + e.printStackTrace(); |
| 2854 | + } |
| 2855 | + AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder() |
| 2856 | + .setConnectionTimeoutInMs(5000) |
| 2857 | + .setSSLContext(sslContext).build(); |
| 2858 | + AsyncHttpClient client = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config); |
| 2859 | + try { |
| 2860 | + long start = System.currentTimeMillis(); |
| 2861 | + try { |
| 2862 | + client.executeRequest(client.prepareGet("http://www.google.com").build()).get(); |
| 2863 | + } catch (InterruptedException e) { |
| 2864 | + e.printStackTrace(); |
| 2865 | + } catch (ExecutionException e) { |
| 2866 | + e.printStackTrace(); |
| 2867 | + } |
| 2868 | + System.out.println("COMPLETE: " + (System.currentTimeMillis() - start) + "ms"); |
| 2869 | + } catch (IOException e) { |
| 2870 | + e.printStackTrace(); |
| 2871 | + } |
| 2872 | + } |
2843 | 2873 | }
|
2844 | 2874 |
|
2845 | 2875 |
|
|
0 commit comments