Tabnine Logo
NettyHttpClient
Code IndexAdd Tabnine to your IDE (free)

How to use
NettyHttpClient
in
com.mpush.netty.http

Best Java code snippets using com.mpush.netty.http.NettyHttpClient (Showing top 4 results out of 315)

origin: mpusher/mpush

public HttpClient getHttpClient() {
  if (httpClient == null) {
    synchronized (this) {
      if (httpClient == null) {
        httpClient = new NettyHttpClient();
      }
    }
  }
  return httpClient;
}
origin: mpusher/mpush

    LOGGER.debug("create new channel cost={}", (System.currentTimeMillis() - startCreate));
    if (future.isSuccess()) {//3.1.把请求写到http server
      writeRequest(future.channel(), context);
    } else {//3.2如果链接创建失败,直接返回客户端网关超时
      context.tryDone();
} else {
  writeRequest(channel, context);
origin: mpusher/mpush

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  RequestContext context = ctx.channel().attr(client.requestKey).getAndSet(null);
  try {
    if (context != null && context.tryDone()) {
      LOGGER.debug("receive server response, request={}, response={}", context, msg);
      HttpResponse response = (HttpResponse) msg;
      if (isRedirect(response)) {
        if (context.onRedirect(response)) {
          String location = getRedirectLocation(context.request, response);
          if (location != null && location.length() > 0) {
            context.cancelled.set(false);
            context.request.setUri(location);
            client.request(context);
            return;
          }
        }
      }
      context.onResponse(response);
    } else {
      LOGGER.warn("receive server response but timeout, request={}, response={}", context, msg);
    }
  } finally {
    client.pool.tryRelease(ctx.channel());
    ReferenceCountUtil.release(msg);
  }
}
origin: com.github.mpusher/mpush-core

public HttpClient getHttpClient() {
  if (httpClient == null) {
    synchronized (this) {
      if (httpClient == null) {
        httpClient = new NettyHttpClient();
      }
    }
  }
  return httpClient;
}
com.mpush.netty.httpNettyHttpClient

Javadoc

Netty的一个Bootstrap是可以关联多个channel的, 本Client采用的就是这种模式,在种模式下如果Handler添加了@ChannelHandler.Sharable 注解的话,要特殊处理,因为这时的client和handler是被所有请求共享的。

Created by ohun on 2016/2/15.

Most used methods

  • <init>
  • request
  • writeRequest

Popular in Java

  • Making http requests using okhttp
  • compareTo (BigDecimal)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (Timer)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • ImageIO (javax.imageio)
  • JPanel (javax.swing)
  • JTable (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now