@@ -293,12 +293,11 @@ public HttpClient build() {
293
293
294
294
// credit: https://github.com/AsyncHttpClient/async-http-client/blob/b52a8de5d6a862b5d1652d62f87ce774cbcff156/src/main/java/com/ning/http/client/ProxyServer.java#L99-L127
295
295
static ProxyServer createProxyServer (final Proxy proxy ) {
296
- if (proxy .type ().equals (Proxy .Type .DIRECT )) {
297
- return null ;
298
- }
299
-
300
- if (!proxy .type ().equals (Proxy .Type .HTTP )) {
301
- throw new IllegalArgumentException ("Only DIRECT and HTTP Proxies are supported!" );
296
+ switch (proxy .type ()) {
297
+ case DIRECT :
298
+ return null ;
299
+ case SOCKS :
300
+ throw new IllegalArgumentException ("Only DIRECT and HTTP Proxies are supported!" );
302
301
}
303
302
304
303
final SocketAddress sa = proxy .address ();
@@ -309,18 +308,15 @@ static ProxyServer createProxyServer(final Proxy proxy) {
309
308
310
309
InetSocketAddress isa = (InetSocketAddress ) sa ;
311
310
312
- if (isa .isUnresolved ()) {
313
- return new ProxyServer (isa .getHostName (), isa .getPort ());
314
- } else {
315
- return new ProxyServer (isa .getAddress ().getHostAddress (), isa .getPort ());
316
- }
311
+ final String isaHost = isa .isUnresolved () ? isa .getHostName () : isa .getAddress ().getHostAddress ();
312
+ return new ProxyServer (isaHost , isa .getPort ());
317
313
}
318
314
}
319
315
320
316
static class TokenAuthRequestFilter implements RequestFilter {
321
317
322
- private int apiKey ;
323
- private String apiSecret ;
318
+ private final int apiKey ;
319
+ private final String apiSecret ;
324
320
private final String authHeader = "X-OPENTOK-AUTH" ;
325
321
326
322
public TokenAuthRequestFilter (int apiKey , String apiSecret ) {
@@ -332,8 +328,7 @@ public FilterContext filter(FilterContext ctx) throws FilterException {
332
328
try {
333
329
return new FilterContext .FilterContextBuilder (ctx )
334
330
.request (new RequestBuilder (ctx .getRequest ())
335
- .addHeader (authHeader ,
336
- TokenGenerator .generateToken (apiKey , apiSecret ))
331
+ .addHeader (authHeader , TokenGenerator .generateToken (apiKey , apiSecret ))
337
332
.build ())
338
333
.build ();
339
334
} catch (OpenTokException e ) {
0 commit comments