当前位置: 首页>>代码示例>>Java>>正文


Java Header.getValue方法代码示例

本文整理汇总了Java中org.apache.http.Header.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Header.getValue方法的具体用法?Java Header.getValue怎么用?Java Header.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.Header的用法示例。


在下文中一共展示了Header.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFormatHeader

import org.apache.http.Header; //导入方法依赖的package包/类
/**
 * Actually formats a header.
 * Called from {@link #formatHeader}.
 *
 * @param buffer    the empty buffer into which to format,
 *                  never <code>null</code>
 * @param header    the header to format, never <code>null</code>
 */
protected void doFormatHeader(final CharArrayBuffer buffer,
                              final Header header) {
    final String name = header.getName();
    final String value = header.getValue();

    int len = name.length() + 2;
    if (value != null) {
        len += value.length();
    }
    buffer.ensureCapacity(len);

    buffer.append(name);
    buffer.append(": ");
    if (value != null) {
        buffer.append(value);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:BasicLineFormatter.java

示例2: bufferHeaderValue

import org.apache.http.Header; //导入方法依赖的package包/类
private void bufferHeaderValue() {
    this.cursor = null;
    this.buffer = null;
    while (this.headerIt.hasNext()) {
        Header h = this.headerIt.nextHeader();
        if (h instanceof FormattedHeader) {
            this.buffer = ((FormattedHeader) h).getBuffer();
            this.cursor = new ParserCursor(0, this.buffer.length());
            this.cursor.updatePos(((FormattedHeader) h).getValuePos());
            break;
        } else {
            String value = h.getValue();
            if (value != null) {
                this.buffer = new CharArrayBuffer(value.length());
                this.buffer.append(value);
                this.cursor = new ParserCursor(0, this.buffer.length());
                break;
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:BasicHeaderElementIterator.java

示例3: getResponseFileName

import org.apache.http.Header; //导入方法依赖的package包/类
/**
 * 从响应消息的Content-Disposition头中获得文件名。
 * 
 * @param headers
 * @return 如果不是文件则返回null
 */
private static String getResponseFileName(Header[] headers) {
	String filename = null;
	if (headers == null) {
		return null;
	}
	for (Header header : headers) {
		if (StringUtils.equalsIgnoreCase(header.getName(), "Content-Disposition")) {
			String value = header.getValue();
			String key = "filename=";
			int keyLength = key.length();
			int position = StringUtils.indexOfIgnoreCase(header.getValue(), key);
			if (position > -1) {
				filename = StringUtils.substring(value, position + keyLength);
			}
			break;
		}
	}
	return filename;
}
 
开发者ID:AlexLee-CN,项目名称:weixin_api,代码行数:26,代码来源:HttpUtil.java

示例4: a

import org.apache.http.Header; //导入方法依赖的package包/类
private static boolean a(HttpResponse httpResponse) {
    String str = null;
    String str2 = a;
    if (httpResponse != null) {
        Header[] allHeaders = httpResponse.getAllHeaders();
        if (allHeaders != null && allHeaders.length > 0) {
            for (Header header : allHeaders) {
                if (header != null) {
                    String name = header.getName();
                    if (name != null && name.equalsIgnoreCase(str2)) {
                        str = header.getValue();
                        break;
                    }
                }
            }
        }
    }
    return Boolean.valueOf(str).booleanValue();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:d.java

示例5: getCookie

import org.apache.http.Header; //导入方法依赖的package包/类
@Override
public CookieStore getCookie() {
    CookieStore store = new CookieStore();
    for (int i = 0; i < headers.length; i++) {
        Header header = headers[i];
        if (header.getName().equals("Set-Cookie")) {
            String cookie = header.getValue();
            QuickHttpController.log("cookie : "+cookie);
            store.putCookie(cookie);
        }
    }
    if (store.size() > 0) {
        return store;
    }
    return null;
}
 
开发者ID:fcibook,项目名称:QuickHttp,代码行数:17,代码来源:HttpResponseBody.java

示例6: getWarcRecordId

import org.apache.http.Header; //导入方法依赖的package包/类
@Override
public UUID getWarcRecordId() {
	final Header header = WarcHeader.getFirstHeader(this.warcHeaders, WarcHeader.Name.WARC_RECORD_ID);
	if (header == null) throw new IllegalStateException(WarcHeader.Name.WARC_RECORD_ID + " mandatory header not present");
	UUID uuid;
	try {
		uuid = WarcHeader.parseId(header.getValue());
	} catch (final WarcFormatException e) {
		throw new IllegalStateException(WarcHeader.Name.WARC_RECORD_ID + " '" + header.getValue() + "' falied parsing", e);
	}
	if (LOGGER.isDebugEnabled()) LOGGER.debug("Got UUID {}, parsed as {}", header.getValue(), uuid);
	return uuid;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:14,代码来源:AbstractWarcRecord.java

示例7: getSha1

import org.apache.http.Header; //导入方法依赖的package包/类
private static HashValue getSha1(HttpResponse response, String etag) {
    Header sha1Header = response.getFirstHeader("X-Checksum-Sha1");
    if (sha1Header != null) {
        return new HashValue(sha1Header.getValue());
    }

    // Nexus uses sha1 etags, with a constant prefix
    // e.g {SHA1{b8ad5573a5e9eba7d48ed77a48ad098e3ec2590b}}
    if (etag != null && etag.startsWith("{SHA1{")) {
        String hash = etag.substring(6, etag.length() - 2);
        return new HashValue(hash);
    }

    return null;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:HttpResponseResource.java

示例8: getLocation

import org.apache.http.Header; //导入方法依赖的package包/类
@Override
public String getLocation() {
    Header locationHeader = response.getFirstHeader("Location");
    if (null == locationHeader) {
        return null;
    }
    return locationHeader.getValue();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:9,代码来源:OneDriveCommonsHttpRequestExecutor.java

示例9: transformRequest

import org.apache.http.Header; //导入方法依赖的package包/类
private static Request transformRequest(HttpRequest request) {
  Request.Builder builder = new Request.Builder();

  RequestLine requestLine = request.getRequestLine();
  String method = requestLine.getMethod();
  builder.url(requestLine.getUri());

  String contentType = null;
  for (Header header : request.getAllHeaders()) {
    String name = header.getName();
    if ("Content-Type".equalsIgnoreCase(name)) {
      contentType = header.getValue();
    } else {
      builder.header(name, header.getValue());
    }
  }

  RequestBody body = null;
  if (request instanceof HttpEntityEnclosingRequest) {
    HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
    if (entity != null) {
      // Wrap the entity in a custom Body which takes care of the content, length, and type.
      body = new HttpEntityBody(entity, contentType);

      Header encoding = entity.getContentEncoding();
      if (encoding != null) {
        builder.header(encoding.getName(), encoding.getValue());
      }
    } else {
      body = Util.EMPTY_REQUEST;
    }
  }
  builder.method(method, body);

  return builder.build();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:OkApacheClient.java

示例10: extractCookies

import org.apache.http.Header; //导入方法依赖的package包/类
private void extractCookies(URI uri, HttpResponse response, Cookies cookies) throws Exception
{
	Header[] headers = response.getHeaders("Set-Cookie");
	for( Header header : headers )
	{
		ACookie cookie = new ACookie(uri, header.getValue());
		cookies.recvd.add(cookie);
		cookies.send.add(cookie);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:HttpServiceImpl.java

示例11: getRedirectLocation

import org.apache.http.Header; //导入方法依赖的package包/类
public static String getRedirectLocation() {
    Header locationHeader = response.getFirstHeader("Location");
    if (locationHeader == null) {
        return null;
    }
    return locationHeader.getValue();
}
 
开发者ID:bluetata,项目名称:crawler-jsoup-maven,代码行数:8,代码来源:CSDNLoginApater.java

示例12: load

import org.apache.http.Header; //导入方法依赖的package包/类
/**
 * load the content of this page from a fetched HttpEntity.
 * @param entity HttpEntity
 * @param maxBytes The maximum number of bytes to read
 * @throws Exception when load fails
 */
public void load(HttpEntity entity, int maxBytes) throws Exception {
    contentType = null;
    Header type = entity.getContentType();
    if (type != null) {
        contentType = type.getValue();
    }
    contentEncoding = null;
    Header encoding = entity.getContentEncoding();
    if (encoding != null) {
        contentEncoding = encoding.getValue();
    }

    Charset charset = ContentType.getOrDefault(entity).getCharset();
    if (charset != null) {
        contentCharset = charset.displayName();
    }else {
        contentCharset = Charset.defaultCharset().displayName();
    }

    contentData = toByteArray(entity, maxBytes);
}
 
开发者ID:doubleview,项目名称:fastcrawler,代码行数:28,代码来源:Page.java

示例13: afterDoCap

import org.apache.http.Header; //导入方法依赖的package包/类
@Override
public void afterDoCap(InvokeChainContext context, Object[] args) {

    if (UAVServer.instance().isExistSupportor("com.creditease.uav.apm.supporters.SlowOperSupporter")) {
        Span span = (Span) context.get(InvokeChainConstants.PARAM_SPAN_KEY);
        SlowOperContext slowOperContext = new SlowOperContext();
        if (Throwable.class.isAssignableFrom(args[0].getClass())) {

            Throwable e = (Throwable) args[0];
            slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_EXCEPTION, e.toString());

        }
        else {
            HttpResponse response = (HttpResponse) args[0];

            slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_HEADER, getResponHeaders(response));
            HttpEntity entity = response.getEntity();
            // 由于存在读取失败和无法缓存的大entity会使套壳失败,故此处添加如下判断
            if (BufferedHttpEntity.class.isAssignableFrom(entity.getClass())) {
                Header header = entity.getContentEncoding();
                String encoding = header == null ? "utf-8" : header.getValue();
                slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_BODY, getHttpEntityContent(entity, encoding));
            }
            else {
                slowOperContext.put(SlowOperConstants.PROTOCOL_HTTP_BODY,
                        "HttpEntityWrapper failed! Maybe HTTP entity too large to be buffered in memory");
            }
        }

        Object params[] = { span, slowOperContext };
        UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.SlowOperSupporter", "runCap",
                span.getEndpointInfo().split(",")[0], InvokeChainConstants.CapturePhase.DOCAP, context, params);
    }

}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:36,代码来源:ApacheHttpClientAdapter.java

示例14: a

import org.apache.http.Header; //导入方法依赖的package包/类
public static InputStream a(HttpEntity httpEntity) {
    InputStream content = httpEntity.getContent();
    if (content == null) {
        return content;
    }
    Header contentEncoding = httpEntity.getContentEncoding();
    if (contentEncoding == null) {
        return content;
    }
    String value = contentEncoding.getValue();
    if (value == null) {
        return content;
    }
    return value.contains(AsyncHttpClient.ENCODING_GZIP) ? new GZIPInputStream(content) : content;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:b.java

示例15: getDownloadFileSize

import org.apache.http.Header; //导入方法依赖的package包/类
public String getDownloadFileSize(Header[] headers) {
    String size = "";
    if (headers == null) {
        return size;
    }
    for (Header header : headers) {
        if (TextUtils.equals(header.getName(), "Content-Length")) {
            size = header.getValue();
        }
    }
    return size.contains("Content-Length: ") ? size.replace("Content-Length: ", "") : size;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:VideoDownloadHelper.java


注:本文中的org.apache.http.Header.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。