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


Java BufferedHeader类代码示例

本文整理汇总了Java中org.apache.http.message.BufferedHeader的典型用法代码示例。如果您正苦于以下问题:Java BufferedHeader类的具体用法?Java BufferedHeader怎么用?Java BufferedHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doResponse

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
/**
 * 处理返回结果数据
 *
 * @param unitTest
 * @param response
 * @throws IOException
 */
private static void doResponse(UnitTest unitTest, CloseableHttpResponse response) throws IOException {
    int statusCode = response.getStatusLine().getStatusCode();
    unitTest.setResponseCode(statusCode);
    StringBuffer sb = new StringBuffer();
    for (int loop = 0; loop < response.getAllHeaders().length; loop++) {
        BufferedHeader header = (BufferedHeader) response
                .getAllHeaders()[loop];
        if (header.getName().equals("Accept-Charset")) {
            continue;
        }
        sb.append(header.getName() + ":" + header.getValue() + "<br/>");
    }
    unitTest.setResponseHeader(sb.toString());
    HttpEntity entity = response.getEntity();
    String result;
    if (entity != null) {
        result = EntityUtils.toString(entity, "utf-8");
        unitTest.setResponseSize(result.getBytes().length);
        unitTest.setResponseBody(result);
    }
    EntityUtils.consume(entity);
    response.close();
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:31,代码来源:HttpUtil.java

示例2: formatCookies

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
public List<Header> formatCookies(final List<Cookie> cookies) {
    if (cookies == null) {
        throw new IllegalArgumentException("List of cookies may not be null");
    }
    if (cookies.isEmpty()) {
        throw new IllegalArgumentException("List of cookies may not be empty");
    }
    CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
    buffer.append(SM.COOKIE);
    buffer.append(": ");
    for (int i = 0; i < cookies.size(); i++) {
        Cookie cookie = cookies.get(i);
        if (i > 0) {
            buffer.append("; ");
        }
        buffer.append(cookie.getName());
        String s = cookie.getValue();
        if (s != null) {
            buffer.append("=");
            buffer.append(s);
        }
    }
    List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BufferedHeader(buffer));
    return headers;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:NetscapeDraftSpec.java

示例3: formatCookies

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
public List<Header> formatCookies(final List<Cookie> cookies) {
    if (cookies == null) {
        throw new IllegalArgumentException("List of cookies may not be null");
    }
    if (cookies.isEmpty()) {
        throw new IllegalArgumentException("List of cookies may not be empty");
    }
    CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
    buffer.append(SM.COOKIE);
    buffer.append(": ");
    for (int i = 0; i < cookies.size(); i++) {
        Cookie cookie = cookies.get(i);
        if (i > 0) {
            buffer.append("; ");
        }
        buffer.append(cookie.getName());
        buffer.append("=");
        String s = cookie.getValue();
        if (s != null) {
            buffer.append(s);
        }
    }
    List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BufferedHeader(buffer));
    return headers;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:BrowserCompatSpec.java

示例4: authenticate

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
/**
 * Returns a Diadoc <tt>Authorization</tt> header value for the given
 * {@link DiadocCredentials}.
 *
 * @param credentials The credentials to encode.
 * @return a Diadoc authorization header
 */
public static Header authenticate(final DiadocCredentials credentials) {
    if (credentials == null) {
        throw new IllegalArgumentException("Credentials may not be null");
    }

    StringBuilder sb = new StringBuilder();
    sb.append("ddauth_api_client_id=");
    sb.append(credentials.getApiClientId());
    if (credentials.getAuthToken() != null) {
        sb.append(",ddauth_token=");
        sb.append(credentials.getAuthToken());
    }

    CharArrayBuffer buffer = new CharArrayBuffer(128);
    buffer.append(AUTH.WWW_AUTH_RESP);
    buffer.append(": DiadocAuth ");
    buffer.append(sb.toString());

    return new BufferedHeader(buffer);
}
 
开发者ID:diadoc,项目名称:diadocsdk-java,代码行数:28,代码来源:DiadocAuthScheme.java

示例5: formatCookies

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
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;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:22,代码来源:NetscapeDraftSpecHC4.java

示例6: formatCookies

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
@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;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:NetscapeDraftSpec.java

示例7: authenticate

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
@Override
public Header authenticate(Credentials credentials, HttpRequest request, HttpContext context)
        throws AuthenticationException {
    Args.notNull(credentials, "Credentials");
    Args.notNull(request, "HTTP request");

    // the bearer token is stored in the password field, not credentials.getUserPrincipal().getName()
    String bearerToken = credentials.getPassword();

    CharArrayBuffer buffer = new CharArrayBuffer(64);
    if (isProxy()) {
        buffer.append("Proxy-Authorization");
    } else {
        buffer.append("Authorization");
    }
    buffer.append(": Bearer ");
    buffer.append(bearerToken);

    return new BufferedHeader(buffer);
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:21,代码来源:JolokiaClientFactory.java

示例8: buildHeaders

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
public List<Header> buildHeaders() {
    ArrayList<Header> headersArr = new ArrayList<>();
    if (!StringUtils.isEmpty(headers)) {
        BufferedReader in = new BufferedReader(new StringReader(headers));

        String str;
        try {
            while ((str = in.readLine()) != null) {
                CharArrayBuffer charArrayBuffer = new CharArrayBuffer(str.length());
                charArrayBuffer.append(str);
                headersArr.add(new BufferedHeader(charArrayBuffer));
            }
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }

    if (entityContentType != null) {
        headersArr.add(entityContentType);
    } else if (contentType != null && !contentType.toString().isEmpty()) {
        headersArr.add(new BasicHeader("Content-Type", contentType.toString()));
    }
    return headersArr;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:25,代码来源:HeadersBuilder.java

示例9: build

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
@Test
public void build() {
    ContentType contentType = ContentType.parse(CONTENT_TYPE);
    List<Header> headers = new HeadersBuilder()
            .setHeaders("header1:value1\nheader2:value2")
            .setContentType(contentType)
            .buildHeaders();
    assertEquals(3, headers.size());
    assertThat(headers.get(0), instanceOf(BufferedHeader.class));
    BufferedHeader basicHeader = (BufferedHeader) headers.get(1);
    assertEquals("header2", basicHeader.getName());
    assertEquals("value2", basicHeader.getValue());
    BasicHeader contentTypeHeader = (BasicHeader) headers.get(2);
    assertEquals("Content-Type", contentTypeHeader.getName());
    assertEquals(CONTENT_TYPE, contentTypeHeader.getValue());
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:17,代码来源:HeadersBuilderTest.java

示例10: getVersionHeader

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
@Override
public Header getVersionHeader() {
    CharArrayBuffer buffer = new CharArrayBuffer(40);
    buffer.append(SM.COOKIE2);
    buffer.append(": ");
    buffer.append("$Version=");
    buffer.append(Integer.toString(getVersion()));
    return new BufferedHeader(buffer);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:RFC2965Spec.java

示例11: doFormatManyHeaders

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
private List<Header> doFormatManyHeaders(final List<Cookie> cookies) {
    List<Header> headers = new ArrayList<Header>(cookies.size());
    for (Cookie cookie : cookies) {
        int version = cookie.getVersion();
        CharArrayBuffer buffer = new CharArrayBuffer(40);
        buffer.append("Cookie: ");
        buffer.append("$Version=");
        buffer.append(Integer.toString(version));
        buffer.append("; ");
        formatCookieAsVer(buffer, cookie, version);
        headers.add(new BufferedHeader(buffer));
    }
    return headers;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:RFC2109Spec.java

示例12: authenticate

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
/**
 * Returns a basic <tt>Authorization</tt> header value for the given
 * {@link Credentials} and charset.
 *
 * @param credentials The credentials to encode.
 * @param charset The charset to use for encoding the credentials
 *
 * @return a basic authorization header
 */
public static Header authenticate(
        final Credentials credentials,
        final String charset,
        boolean proxy) {
    if (credentials == null) {
        throw new IllegalArgumentException("Credentials may not be null");
    }
    if (charset == null) {
        throw new IllegalArgumentException("charset may not be null");
    }

    StringBuilder tmp = new StringBuilder();
    tmp.append(credentials.getUserPrincipal().getName());
    tmp.append(":");
    tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());

    byte[] base64password = Base64.encodeBase64(
            EncodingUtils.getBytes(tmp.toString(), charset));

    CharArrayBuffer buffer = new CharArrayBuffer(32);
    if (proxy) {
        buffer.append(AUTH.PROXY_AUTH_RESP);
    } else {
        buffer.append(AUTH.WWW_AUTH_RESP);
    }
    buffer.append(": Basic ");
    buffer.append(base64password, 0, base64password.length);

    return new BufferedHeader(buffer);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:BasicScheme.java

示例13: getVersionHeader

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
@Override
public Header getVersionHeader() {
    final CharArrayBuffer buffer = new CharArrayBuffer(40);
    buffer.append(SM.COOKIE2);
    buffer.append(": ");
    buffer.append("$Version=");
    buffer.append(Integer.toString(getVersion()));
    return new BufferedHeader(buffer);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:10,代码来源:RFC2965SpecHC4.java

示例14: doFormatManyHeaders

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
private List<Header> doFormatManyHeaders(final List<Cookie> cookies) {
    final List<Header> headers = new ArrayList<Header>(cookies.size());
    for (final Cookie cookie : cookies) {
        final int version = cookie.getVersion();
        final CharArrayBuffer buffer = new CharArrayBuffer(40);
        buffer.append("Cookie: ");
        buffer.append("$Version=");
        buffer.append(Integer.toString(version));
        buffer.append("; ");
        formatCookieAsVer(buffer, cookie, version);
        headers.add(new BufferedHeader(buffer));
    }
    return headers;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:RFC2109SpecHC4.java

示例15: formatCookies

import org.apache.http.message.BufferedHeader; //导入依赖的package包/类
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("; ");
        }
        final String cookieName = cookie.getName();
        final String cookieValue = cookie.getValue();
        if (cookie.getVersion() > 0 && !isQuoteEnclosed(cookieValue)) {
            BasicHeaderValueFormatterHC4.INSTANCE.formatHeaderElement(
                    buffer,
                    new BasicHeaderElement(cookieName, cookieValue),
                    false);
        } else {
            // Netscape style cookies do not support quoted values
            buffer.append(cookieName);
            buffer.append("=");
            if (cookieValue != null) {
                buffer.append(cookieValue);
            }
        }
    }
    final List<Header> headers = new ArrayList<Header>(1);
    headers.add(new BufferedHeader(buffer));
    return headers;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:31,代码来源:BrowserCompatSpecHC4.java


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