org.apache.commons.httpclient.Header.toString()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(135)

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

Header.toString介绍

[英]Returns a String representation of the header.
[中]返回标头的字符串表示形式。

代码示例

代码示例来源:origin: edu.ucar/netcdf

private void printHeaders(String title, Header[] heads) {
 System.out.println(title);
 for (Header head : heads) {
  System.out.print("  " + head.toString());
 }
 System.out.println();
}

代码示例来源:origin: mozilla/zest

private String arrayToStr(Header[] headers) {
  StringBuilder sb = new StringBuilder();
  for (Header header : headers) {
    sb.append(header.toString());
  }
  return sb.toString();
}

代码示例来源:origin: stackoverflow.com

HttpEntity entity = response.getEntity();
// technically you should check the HTTP response rather than assume it is a 200
int statusCode = httpResp.getStatusLine().getStatusCode();
if(statusCode != 200)
  ... // do something with non 200 responses ?

clientSocket.write("HTTP/1.1 200 OK\r\n");

Header[] responseHeaders = response.getAllHeaders();
for(Header header : responseHeaders) {
   clientSocket.write(header.toString() + "\r\n");
}

clientSocket.write("\r\n"); // empty line required

// Use BufferedInputStream to deal in bytes
BufferedInputStream input = new BufferedInputStream(entity.getContent());
byte[] buf = new byte[8192];
int bytesRead;
while ((bytesRead = input.read(buf, 8192)) > 0) {
  clientSocket.write(buf, bytesRead);
}

代码示例来源:origin: stackoverflow.com

// So we can get all the headers (not just the ones we explicitly set).        
httpClient.addRequestInterceptor(new HttpRequestInterceptor() {

  public void process(
      final HttpRequest request,
      final HttpContext context) 
      throws HttpException, IOException {

    // Start Debug
    System.out.println("*** Request headers ***");
    Header[] requestHeaders = request.getAllHeaders();
    for(Header header : requestHeaders) {
      System.out.println(header.toString());
    }
    System.out.println("***********************");
    // End Debug
  }

});

代码示例来源:origin: stackoverflow.com

HttpClient client = HttpClients.createDefault();
HttpCoreContext localContext = new HttpCoreContext();
HttpResponse response = client.execute(request,localContext);

Header[] headers = localContext.getRequest().getAllHeaders();
for (Header header : headers) {
  System.out.println(header.toString());
}

代码示例来源:origin: org.littleshoot/http-client

private void notifyRange(final Header rangeHeader) throws IOException
  {
  String rangeString = rangeHeader.getValue().trim();
  if (!rangeString.startsWith("bytes"))
    {
    m_log.warn("Bad header!!  {}", rangeHeader);
    this.m_listener.onBadHeader(rangeHeader.toString());
    throw new IOException("Could not read header: "+rangeHeader);
    }
  
  rangeString = 
    StringUtils.substringBetween(rangeString, "bytes", "/").trim();
  
  final String minString = 
    StringUtils.substringBefore(rangeString, "-").trim();
  final String maxString = 
    StringUtils.substringAfter(rangeString, "-").trim();
  final long min = Long.parseLong(minString);
  final long max = Long.parseLong(maxString);
  final LongRange range = new LongRange(min, max);
  m_listener.onContentRange(range);
  }
}

代码示例来源:origin: openstack/sahara-extra

/**
 * Execute the request with the request and response logged at debug level
 * @param method method to execute
 * @param client client to use
 * @param <M> method type
 * @return the status code
 * @throws IOException any failure reported by the HTTP client.
 */
private <M extends HttpMethod> int execWithDebugOutput(M method,
                            HttpClient client) throws
    IOException {
 if (LOG.isDebugEnabled()) {
  StringBuilder builder = new StringBuilder(
      method.getName() + " " + method.getURI() + "\n");
  for (Header header : method.getRequestHeaders()) {
   builder.append(header.toString());
  }
  LOG.debug(builder);
 }
 int statusCode = client.executeMethod(method);
 if (LOG.isDebugEnabled()) {
  LOG.debug("Status code = " + statusCode);
 }
 return statusCode;
}

代码示例来源:origin: org.astrogrid/astrogrid-cea-server

if (contentEncoding != null && contentEncoding.toString().length() == 0) {
 return method.getResponseBody();
  (contentType.toString().indexOf("text/") != -1 ||
   contentType.toString().indexOf("xml") != -1)) {
 return method.getResponseBodyAsString();

代码示例来源:origin: slide/slide-webdavlib

for (int i = 0; i < headers.length; i++) {
 Header header = headers[i];
 System.out.print(header.toString());

代码示例来源:origin: openstack/sahara-extra

lastModified = simpleDateFormat.parse(header.getValue()).getTime();
} catch (ParseException e) {
 throw new SwiftException("Failed to parse " + header.toString(), e);

代码示例来源:origin: stackoverflow.com

parseID3v2Frames(id3v2, aff_properties);
if (TDebug.TraceAudioFileReader) TDebug.out(m_header.toString());

代码示例来源:origin: slide/slide-webdavlib

for (int i = 0; i < headers.length; i++) {
  Header header = headers[i];
  System.out.print(header.toString());

相关文章