org.apache.http.util.Args类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(193)

本文整理了Java中org.apache.http.util.Args类的一些代码示例,展示了Args类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Args类的具体详情如下:
包路径:org.apache.http.util.Args
类名称:Args

Args介绍

暂无

代码示例

代码示例来源:origin: internetarchive/heritrix3

/**
 * Creates an instance of this class using the given request line.
 *
 * @param requestline request line.
 */
public BasicExecutionAwareRequest(final RequestLine requestline) {
  super();
  this.requestline = Args.notNull(requestline, "Request line");
  this.method = requestline.getMethod();
  this.uri = requestline.getUri();
}

代码示例来源:origin: apache/storm

/**
 * Construct an Elasticsearch endpoint from the provided index, type and
 * id.
 * @param index - required; name of Elasticsearch index
 * @param type - optional; name of Elasticsearch type
 * @param id - optional; Elasticsearch document ID
 * @return the index, type and id concatenated with '/'.
 */
static String getEndpoint(String index, String type, String id) {
  requireNonNull(index);
  notBlank(index, "index");
  StringBuilder sb = new StringBuilder();
  sb.append("/").append(index);
  if (!(type == null || type.isEmpty())) {
    sb.append("/").append(type);
  }
  if (!(id == null || id.isEmpty())) {
    sb.append("/").append(id);
  }
  return sb.toString();
}

代码示例来源:origin: ibinti/bugvm

/**
 * Obtains value of the {@link CoreProtocolPNames#HTTP_CONTENT_CHARSET} parameter.
 * If not set, defaults to {@code ISO-8859-1}.
 *
 * @param params HTTP parameters.
 * @return HTTP content charset.
 */
public static String getContentCharset(final HttpParams params) {
  Args.notNull(params, "HTTP parameters");
  String charset = (String) params.getParameter
    (CoreProtocolPNames.HTTP_CONTENT_CHARSET);
  if (charset == null) {
    charset = HTTP.DEF_CONTENT_CHARSET.name();
  }
  return charset;
}

代码示例来源:origin: org.apache.httpcomponents/httpclient-android

final HttpResponse response,
  final HttpContext context) throws MalformedChallengeException {
Args.notNull(response, "HTTP response");
final Header[] headers = response.getHeaders(this.headerName);
final Map<String, Header> map = new HashMap<String, Header>(headers.length);
  int pos;
  if (header instanceof FormattedHeader) {
    buffer = ((FormattedHeader) header).getBuffer();
    pos = ((FormattedHeader) header).getValuePos();
  } else {
    final String s = header.getValue();
    if (s == null) {
      throw new MalformedChallengeException("Header value is null");
    buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    pos = 0;
  while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) {
    pos++;

代码示例来源:origin: org.apache.httpcomponents/httpclient-android

public List<Cookie> parse(final Header header, final CookieOrigin origin)
    throws MalformedCookieException {
  Args.notNull(header, "Header");
  Args.notNull(origin, "Cookie origin");
  final String headername = header.getName();
  if (!headername.equalsIgnoreCase(SM.SET_COOKIE)) {
    throw new MalformedCookieException("Unrecognized cookie header '"
        + header.toString() + "'");
  HeaderElement[] helems = header.getElements();
  boolean versioned = false;
  boolean netscape = false;
    final ParserCursor cursor;
    if (header instanceof FormattedHeader) {
      buffer = ((FormattedHeader) header).getBuffer();
      cursor = new ParserCursor(
          ((FormattedHeader) header).getValuePos(),
          buffer.length());
    } else {
      final String s = header.getValue();
      if (s == null) {
        throw new MalformedCookieException("Header value is null");
      buffer = new CharArrayBuffer(s.length());
      buffer.append(s);
      cursor = new ParserCursor(0, buffer.length());

代码示例来源:origin: ibinti/bugvm

@Override
public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  if (!request.containsHeader(HTTP.EXPECT_DIRECTIVE)) {
    if (request instanceof HttpEntityEnclosingRequest) {
      final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
      final HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
      // Do not send the expect header if request body is known to be empty
      if (entity != null
          && entity.getContentLength() != 0 && !ver.lessEquals(HttpVersion.HTTP_1_0)) {
        final boolean active = request.getParams().getBooleanParameter(
            CoreProtocolPNames.USE_EXPECT_CONTINUE, this.activeByDefault);
        if (active) {
          request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.httpcomponents/httpclient-android

public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  final String method = request.getRequestLine().getMethod();
  if (method.equalsIgnoreCase("CONNECT")) {
    return;
  }
  // Add default headers
  @SuppressWarnings("unchecked")
  Collection<? extends Header> defHeaders = (Collection<? extends Header>)
    request.getParams().getParameter(ClientPNames.DEFAULT_HEADERS);
  if (defHeaders == null) {
    defHeaders = this.defaultHeaders;
  }
  if (defHeaders != null) {
    for (final Header defHeader : defHeaders) {
      request.addHeader(defHeader);
    }
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpcore

public void process(final HttpRequest request, final HttpContext context)
  throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  if (!request.containsHeader(HTTP.USER_AGENT)) {
    String s = null;
    final HttpParams params = request.getParams();
    if (params != null) {
      s = (String) params.getParameter(CoreProtocolPNames.USER_AGENT);
    }
    if (s == null) {
      s = this.userAgent;
    }
    if (s != null) {
      request.addHeader(HTTP.USER_AGENT, s);
    }
  }
}

代码示例来源:origin: ibinti/bugvm

public static
  RequestLine parseRequestLine(final String value,
                 final LineParser parser) throws ParseException {
  Args.notNull(value, "Value");
  final CharArrayBuffer buffer = new CharArrayBuffer(value.length());
  buffer.append(value);
  final ParserCursor cursor = new ParserCursor(0, value.length());
  return (parser != null ? parser : BasicLineParser.INSTANCE)
    .parseRequestLine(buffer, cursor);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Sets value of the {@link CoreProtocolPNames#HTTP_ELEMENT_CHARSET} parameter.
 *
 * @param params HTTP parameters.
 * @param charset HTTP element charset.
 */
public static void setHttpElementCharset(final HttpParams params, final String charset) {
  Args.notNull(params, "HTTP parameters");
  params.setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET, charset);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public List<Header> formatCookies(final List<Cookie> cookies) {
  Args.notEmpty(cookies, "List of cookies");
  final CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
  buffer.append(SM.COOKIE);
  buffer.append(": ");
  for (int i = 0; i < cookies.size(); i++) {
    final Cookie cookie = cookies.get(i);
    if (i > 0) {
      buffer.append("; ");
    }
    buffer.append(cookie.getName());
    final String s = cookie.getValue();
    if (s != null) {
      buffer.append("=");
      buffer.append(s);
    }
  }
  final List<Header> headers = new ArrayList<Header>(1);
  headers.add(new BufferedHeader(buffer));
  return headers;
}

代码示例来源:origin: ibinti/bugvm

/**
 * Sets value of the {@link CoreConnectionPNames#SO_TIMEOUT} parameter.
 *
 * @param params HTTP parameters.
 * @param timeout SO_TIMEOUT.
 */
public static void setSoTimeout(final HttpParams params, final int timeout) {
  Args.notNull(params, "HTTP parameters");
  params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, timeout);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Creates a new header from a buffer.
 * The name of the header will be parsed immediately,
 * the value only if it is accessed.
 *
 * @param buffer    the buffer containing the header to represent
 *
 * @throws ParseException   in case of a parse error
 */
public BufferedHeader(final CharArrayBuffer buffer)
  throws ParseException {
  super();
  Args.notNull(buffer, "Char array buffer");
  final int colon = buffer.indexOf(':');
  if (colon == -1) {
    throw new ParseException
      ("Invalid header: " + buffer.toString());
  }
  final String s = buffer.substringTrimmed(0, colon);
  if (s.length() == 0) {
    throw new ParseException
      ("Invalid header: " + buffer.toString());
  }
  this.buffer = buffer;
  this.name = s;
  this.valuePos = colon + 1;
}

代码示例来源:origin: ibinti/bugvm

/**
 * Sets value of the {@link CoreConnectionPNames#STALE_CONNECTION_CHECK}
 * parameter.
 *
 * @param params HTTP parameters.
 * @param value stale connection check flag.
 */
public static void setStaleCheckingEnabled(final HttpParams params, final boolean value) {
  Args.notNull(params, "HTTP parameters");
  params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, value);
}

代码示例来源:origin: OrienteerBAP/Orienteer

public GeneratorMode(String name, Class<? extends IGeneratorStrategy> strategyClass) {
  Args.notEmpty(name, "name");
  Args.notNull(strategyClass, "strategyClass");
  this.name = name;
  this.strategyClass = strategyClass;
}

代码示例来源:origin: docker-java/docker-java

/**
 * Wraps session input stream and reads chunk coded input.
 *
 * @param in The session input buffer
 * @param constraints Message constraints. If {@code null}
 *   {@link MessageConstraints#DEFAULT} will be used.
 *
 * @since 4.4
 */
public ChunkedInputStream(final SessionInputBuffer in, final MessageConstraints constraints) {
  super();
  this.in = Args.notNull(in, "Session input buffer");
  this.pos = 0L;
  this.buffer = new CharArrayBuffer(16);
  this.constraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
  this.state = CHUNK_LEN;
}

代码示例来源:origin: ibinti/bugvm

/**
 * Obtains value of the {@link CoreConnectionPNames#SOCKET_BUFFER_SIZE}
 * parameter. If not set, defaults to {@code -1}.
 *
 * @param params HTTP parameters.
 * @return socket buffer size
 */
public static int getSocketBufferSize(final HttpParams params) {
  Args.notNull(params, "HTTP parameters");
  return params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
}

代码示例来源:origin: internetarchive/heritrix3

/**
 * Creates an instance of this class using the given request method
 * and URI.
 *
 * @param method request method.
 * @param uri request URI.
 */
public BasicExecutionAwareRequest(final String method, final String uri) {
  super();
  this.method = Args.notNull(method, "Method name");
  this.uri = Args.notNull(uri, "Request URI");
  this.requestline = null;
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

InternalHttpRequest(final String method, final URI requestURI) {
  Args.notBlank(method, "Method");
  Args.notNull(requestURI, "Request URI");
  this.method = method;
  this.uri = requestURI;
  this.aborted = new AtomicBoolean(false);
  this.cancellableRef = new AtomicReference<Cancellable>(null);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Create a protocol version designator.
 *
 * @param protocol   the name of the protocol, for example "HTTP"
 * @param major      the major version number of the protocol
 * @param minor      the minor version number of the protocol
 */
public ProtocolVersion(final String protocol, final int major, final int minor) {
  this.protocol = Args.notNull(protocol, "Protocol name");
  this.major = Args.notNegative(major, "Protocol minor version");
  this.minor = Args.notNegative(minor, "Protocol minor version");
}

相关文章