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


Java HeaderIterator类代码示例

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


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

示例1: getAllowedMethods

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public Set<String> getAllowedMethods(final HttpResponse response) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }

    HeaderIterator it = response.headerIterator("Allow");
    Set<String> methods = new HashSet<String>();
    while (it.hasNext()) {
        Header header = it.nextHeader();
        HeaderElement[] elements = header.getElements();
        for (HeaderElement element : elements) {
            methods.add(element.getName());
        }
    }
    return methods;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:HttpOptions.java

示例2: headerIterator

import org.apache.http.HeaderIterator; //导入依赖的package包/类
@Override public HeaderIterator headerIterator() {
  return new HeaderIterator() {
    int index = 0;

    @Override public boolean hasNext() {
      return index < headers.length;
    }

    @Override public Header nextHeader() {
      if (index >= headers.length) throw new NoSuchElementException();
      return headers[index++];
    }

    @Override public Object next() {
      return nextHeader();
    }

    @Override public void remove() {
      throw new UnsupportedOperationException();
    }
  };
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:23,代码来源:TestHttpResponse.java

示例3: shouldSupportHeaderIteratorWithArg

import org.apache.http.HeaderIterator; //导入依赖的package包/类
@Test
public void shouldSupportHeaderIteratorWithArg() throws Exception {
  HttpResponse resp =
      new TestHttpResponse(304, "REDIRECTED",
          new BasicHeader("Location", "http://bar.com"),
          new BasicHeader("X-Zombo-Com", "http://zombo.com"),
          new BasicHeader("Location", "http://foo.com"));

  HeaderIterator it = resp.headerIterator("Location");

  assertThat(it.hasNext()).isTrue();
  assertThat(it.nextHeader().getValue()).isEqualTo("http://bar.com");
  assertThat(it.hasNext()).isTrue();
  assertThat(it.nextHeader().getValue()).isEqualTo("http://foo.com");
  assertThat(it.hasNext()).isFalse();
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:17,代码来源:TestHttpResponseTest.java

示例4: getAllowedMethods

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public Set<String> getAllowedMethods(final HttpResponse response) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    
    HeaderIterator it = response.headerIterator("Allow");
    Set<String> methods = new HashSet<String>();
    while (it.hasNext()) {
        Header header = it.nextHeader();
        HeaderElement[] elements = header.getElements();
        for (HeaderElement element : elements) {
            methods.add(element.getName());
        }
    }
    return methods;
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:17,代码来源:HttpOptions.java

示例5: receiveRequest

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public HttpRequest receiveRequest() throws HttpException, IOException {
    HttpRequest request = (HttpRequest) this.requestParser.parse();
    if (HEADERLOG.isDebugEnabled()) {
        HEADERLOG.debug(">> " + request.getRequestLine().toString());
        for (HeaderIterator it = request.headerIterator(); it.hasNext(); ) {
            HEADERLOG.debug(">> " + it.nextHeader().toString());
        }
    }
    
    // Prepare input stream
    this.in = null;
    if (request instanceof HttpEntityEnclosingRequest) {
        long len = this.contentLenStrategy.determineLength(request);
        if (len == ContentLengthStrategy.CHUNKED) {
            this.in = new ChunkedInputStream(this.inbuffer);
        } else if (len == ContentLengthStrategy.IDENTITY) {
            this.in = new IdentityInputStream(this.inbuffer);                            
        } else {
            this.in = new ContentLengthInputStream(inbuffer, len);
        }
    }
    return request;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:AxisHttpConnectionImpl.java

示例6: buildResponseStr

import org.apache.http.HeaderIterator; //导入依赖的package包/类
/**
 * Render the headers and the response content as a string.
 * This could include more things such as the status code.
 * 
 * @param response
 * @return A string consisting of the HTTP Response headers nicely formatted.
 */
 public String buildResponseStr(CloseableHttpResponse response) {
    StringBuilder sb = new StringBuilder();
    
    HeaderIterator hi = response.headerIterator();
    while (hi.hasNext()) {
        Header header = hi.nextHeader();
        sb.append(header.getName()).append(": ").append(header.getValue()).append("\r\n");                        
    }
    sb.append("\r\n");
    try {
        sb.append(EntityUtils.toString(response.getEntity()));            
    } catch (IOException | IllegalStateException ex) {
        // Don't care
    }
    
    return sb.toString();
}
 
开发者ID:TAXIIProject,项目名称:java-taxii,代码行数:25,代码来源:HttpResponseErrorHandler.java

示例7: removeHeaders

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public void removeHeaders(final String name) {
    if (name == null) {
        return;
    }
    for (HeaderIterator i = this.headergroup.iterator(); i.hasNext(); ) {
        Header header = i.nextHeader();
        if (name.equalsIgnoreCase(header.getName())) {
            i.remove();
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AbstractHttpMessage.java

示例8: BasicHeaderElementIterator

import org.apache.http.HeaderIterator; //导入依赖的package包/类
/**
 * Creates a new instance of BasicHeaderElementIterator
 */
public BasicHeaderElementIterator(
        final HeaderIterator headerIterator,
        final HeaderValueParser parser) {
    if (headerIterator == null) {
        throw new IllegalArgumentException("Header iterator may not be null");
    }
    if (parser == null) {
        throw new IllegalArgumentException("Parser may not be null");
    }
    this.headerIt = headerIterator;
    this.parser = parser;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:BasicHeaderElementIterator.java

示例9: BasicTokenIterator

import org.apache.http.HeaderIterator; //导入依赖的package包/类
/**
 * Creates a new instance of {@link BasicTokenIterator}.
 *
 * @param headerIterator    the iterator for the headers to tokenize
 */
public BasicTokenIterator(final HeaderIterator headerIterator) {
    if (headerIterator == null) {
        throw new IllegalArgumentException
            ("Header iterator must not be null.");
    }

    this.headerIt = headerIterator;
    this.searchPos = findNext(-1);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:BasicTokenIterator.java

示例10: write

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public void write(final T message) throws IOException, HttpException {
    if (message == null) {
        throw new IllegalArgumentException("HTTP message may not be null");
    }
    writeHeadLine(message);
    for (HeaderIterator it = message.headerIterator(); it.hasNext(); ) {
        Header header = it.nextHeader();
        this.sessionBuffer.writeLine
            (lineFormatter.formatHeader(this.lineBuf, header));
    }
    this.lineBuf.clear();
    this.sessionBuffer.writeLine(this.lineBuf);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AbstractMessageWriter.java

示例11: writeHeaders

import org.apache.http.HeaderIterator; //导入依赖的package包/类
protected static void writeHeaders(final HeaderGroup headers, final OutputStream output) throws IOException {
	for (final HeaderIterator it = headers.iterator(); it.hasNext();) {
		final org.apache.http.Header header = it.nextHeader();
		Util.toOutputStream(BasicLineFormatter.formatHeader(header, null), output);
		output.write(ByteArraySessionOutputBuffer.CRLF);
	}
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:8,代码来源:AbstractWarcRecord.java

示例12: keys

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public static Set<String> keys(HeaderGroup hg) {
	Set<String> ret = new HashSet<>();
	for (HeaderIterator it = hg.iterator(); it.hasNext();) {
		Header header = it.nextHeader();
		ret.add(header.getName().toLowerCase());
	}
	return ret;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:9,代码来源:InputStreamTestMocks.java

示例13: getAllowedMethods

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public Set<String> getAllowedMethods(final HttpResponse response) {
    Args.notNull(response, "HTTP response");

    final HeaderIterator it = response.headerIterator("Allow");
    final Set<String> methods = new HashSet<String>();
    while (it.hasNext()) {
        final Header header = it.nextHeader();
        final HeaderElement[] elements = header.getElements();
        for (final HeaderElement element : elements) {
            methods.add(element.getName());
        }
    }
    return methods;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:HttpOptionsHC4.java

示例14: removeHeaders

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public RequestBuilder removeHeaders(final String name) {
    if (name == null || headergroup == null) {
        return this;
    }
    for (final HeaderIterator i = headergroup.iterator(); i.hasNext(); ) {
        final Header header = i.nextHeader();
        if (name.equalsIgnoreCase(header.getName())) {
            i.remove();
        }
    }
    return this;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:13,代码来源:RequestBuilder.java

示例15: write

import org.apache.http.HeaderIterator; //导入依赖的package包/类
public void write(final HttpMessage message) throws IOException, HttpException {
    Args.notNull(message, "HTTP message");
    writeHeadLine(message);
    for (final HeaderIterator it = message.headerIterator(); it.hasNext(); ) {
        final Header header = it.nextHeader();
        this.sessionBuffer.writeLine
            (lineFormatter.formatHeader(this.lineBuf, header));
    }
    this.lineBuf.clear();
    this.sessionBuffer.writeLine(this.lineBuf);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:12,代码来源:AbstractMessageWriterHC4.java


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