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

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

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

Header.<init>介绍

[英]Default constructor.
[中]默认构造函数。

代码示例

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Create a <tt>"Cookie"</tt> {@link Header} containing all {@link Cookie}s
 * in <i>cookies</i>.
 * @param cookies an array of {@link Cookie}s to be formatted as a <tt>"
 * Cookie"</tt> header
 * @return a <tt>"Cookie"</tt> {@link Header}.
 */
public Header formatCookieHeader(Cookie[] cookies) {
  LOG.trace("enter CookieSpecBase.formatCookieHeader(Cookie[])");
  return new Header("Cookie", formatCookies(cookies));
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Create a <tt>"Cookie"</tt> {@link Header} containing the {@link Cookie}.
 * @param cookie <tt>Cookie</tt>s to be formatted as a <tt>Cookie</tt>
 * header
 * @return a Cookie header.
 */
public Header formatCookieHeader(Cookie cookie) {
  LOG.trace("enter CookieSpecBase.formatCookieHeader(Cookie)");
  return new Header("Cookie", formatCookie(cookie));
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Set the specified request header, overwriting any previous value. Note
 * that header-name matching is case-insensitive.
 *
 * @param headerName the header's name
 * @param headerValue the header's value
 */
public void setRequestHeader(String headerName, String headerValue) {
  Header header = new Header(headerName, headerValue);
  setRequestHeader(header);
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Adds the specified request header, NOT overwriting any previous value.
 * Note that header-name matching is case insensitive.
 *
 * @param headerName the header's name
 * @param headerValue the header's value
 */
public void addRequestHeader(String headerName, String headerValue) {
  addRequestHeader(new Header(headerName, headerValue));
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Gets a header representing all of the header values with the given name.
 * If more that one header with the given name exists the values will be
 * combined with a "," as per RFC 2616.
 * 
 * <p>Header name comparison is case insensitive.
 * 
 * @param name the name of the header(s) to get
 * @return a header with a condensed value or <code>null</code> if no
 * headers by the given name are present
 */
public Header getCondensedHeader(String name) {
  Header[] headers = getHeaders(name);
  
  if (headers.length == 0) {
    return null;   
  } else if (headers.length == 1) {
    return new Header(headers[0].getName(), headers[0].getValue());
  } else {
    StringBuffer valueBuffer = new StringBuffer(headers[0].getValue());
    
    for (int i = 1; i < headers.length; i++) {
      valueBuffer.append(", ");
      valueBuffer.append(headers[i].getValue());
    }
    
    return new Header(name.toLowerCase(), valueBuffer.toString());
  }
}

代码示例来源:origin: elastic/elasticsearch-hadoop

public HeaderProcessor(Settings settings) {
  Map<String, String> workingHeaders = new HashMap<String, String>();
  for (Map.Entry<Object, Object> prop : settings.asProperties().entrySet()) {
    String key = prop.getKey().toString();
    if (key.startsWith(ES_NET_HTTP_HEADER_PREFIX)) {
      String headerName = key.substring(ES_NET_HTTP_HEADER_PREFIX.length());
      validateName(headerName, prop);
      ensureNotReserved(headerName, workingHeaders);
      workingHeaders.put(headerName, extractHeaderValue(prop.getValue()));
    }
  }
  this.headers = new ArrayList<Header>(workingHeaders.keySet().size());
  for (Map.Entry<String, String> headerData : workingHeaders.entrySet()) {
    headers.add(new Header(headerData.getKey(), headerData.getValue()));
  }
  for (ReservedHeaders reservedHeaders : ReservedHeaders.values()) {
    headers.add(new Header(reservedHeaders.getName(), reservedHeaders.getDefaultValue()));
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

public Header getVersionHeader() {
  ParameterFormatter formatter = new ParameterFormatter();
  StringBuffer buffer = new StringBuffer();
  formatter.format(buffer, new NameValuePair("$Version",
      Integer.toString(getVersion())));
  return new Header("Cookie2", buffer.toString(), true);
}

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

public class MainActivity extends ListActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    List<Item> items = new ArrayList<Item>();
    items.add(new Header("Header 1"));
    items.add(new ListItem("Text 1", "Rabble rabble"));
    items.add(new ListItem("Text 2", "Rabble rabble"));
    items.add(new ListItem("Text 3", "Rabble rabble"));
    items.add(new ListItem("Text 4", "Rabble rabble"));
    items.add(new Header("Header 2"));
    items.add(new ListItem("Text 5", "Rabble rabble"));
    items.add(new ListItem("Text 6", "Rabble rabble"));
    items.add(new ListItem("Text 7", "Rabble rabble"));
    items.add(new ListItem("Text 8", "Rabble rabble"));

    TwoTextArrayAdapter adapter = new TwoTextArrayAdapter(this, items);
    setListAdapter(adapter);
  }

}

代码示例来源:origin: commons-httpclient/commons-httpclient

headers.add(new Header(name, value.toString()));
headers.add(new Header(name, value.toString()));

代码示例来源:origin: commons-httpclient/commons-httpclient

if (auth != null) {
  String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP;
  Header header = new Header(s, auth, true);
  method.addRequestHeader(header);
  return true;

代码示例来源:origin: elastic/elasticsearch-hadoop

@Test
public void testApplyArrayValues() throws Exception {
  Settings settings = new TestSettings();
  settings.asProperties().put("es.net.http.header.Accept-Encoding", new Object[]{"gzip","deflate"});
  Header[] headers = applyHeaders(settings);
  assertThat(headers, arrayWithSize(3));
  assertThat(headers, arrayContainingInAnyOrder(
      new Header("Accept", "application/json"),
      new Header("Content-Type", "application/json"),
      new Header("Accept-Encoding", "gzip,deflate")
  ));
}

代码示例来源:origin: openhab/openhab1-addons

if (httpHeaders != null) {
  for (String httpHeaderKey : httpHeaders.stringPropertyNames()) {
    method.addRequestHeader(new Header(httpHeaderKey, httpHeaders.getProperty(httpHeaderKey)));

代码示例来源:origin: elastic/elasticsearch-hadoop

@Test
public void testApplyValidHeader() throws Exception {
  Settings settings = new TestSettings();
  settings.setProperty("es.net.http.header.Max-Forwards", "10");
  Header[] headers = applyHeaders(settings);
  assertThat(headers, arrayWithSize(3));
  assertThat(headers, arrayContainingInAnyOrder(
      new Header("Accept", "application/json"),
      new Header("Content-Type", "application/json"),
      new Header("Max-Forwards", "10")
  ));
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Returns the request's charset.  The charset is parsed from the request entity's 
 * content type, unless the content type header has been set manually. 
 * 
 * @see RequestEntity#getContentType()
 * 
 * @since 3.0
 */
public String getRequestCharSet() {
  if (getRequestHeader("Content-Type") == null) {
    // check the content type from request entity
    // We can't call getRequestEntity() since it will probably call
    // this method.
    if (this.requestEntity != null) {
      return getContentCharSet(
        new Header("Content-Type", requestEntity.getContentType()));
    } else {
      return super.getRequestCharSet();
    }
  } else {
    return super.getRequestCharSet();
  }
}

代码示例来源:origin: elastic/elasticsearch-hadoop

@Test
  public void testApplyMultiValues() throws Exception {
    Settings settings = new TestSettings();
    settings.setProperty("es.net.http.header.Accept-Encoding", "gzip,deflate");

    Header[] headers = applyHeaders(settings);

    assertThat(headers, arrayWithSize(3));
    assertThat(headers, arrayContainingInAnyOrder(
        new Header("Accept", "application/json"),
        new Header("Content-Type", "application/json"),
        new Header("Accept-Encoding", "gzip,deflate")
    ));
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

if (auth != null) {
  String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP;
  Header header = new Header(s, auth, true);
  method.addRequestHeader(header);
  return true;

代码示例来源:origin: commons-httpclient/commons-httpclient

String authstring = authscheme.authenticate(credentials, method);
if (authstring != null) {
  method.addRequestHeader(new Header(PROXY_AUTH_RESP, authstring, true));

代码示例来源:origin: commons-httpclient/commons-httpclient

String authstring = authscheme.authenticate(credentials, method);
if (authstring != null) {
  method.addRequestHeader(new Header(WWW_AUTH_RESP, authstring, true));

代码示例来源:origin: commons-httpclient/commons-httpclient

getRequestHeaderGroup().addHeader(new Header("Cookie", s, true));
} else {
    getRequestHeaderGroup().addHeader(new Header("Cookie", s, true));

代码示例来源:origin: org.mule.transports/mule-transport-http

protected void setContentType(HttpResponse response, MuleMessage message)
{
  if(contentType == null)
  {
    contentType = getDefaultContentType(message);
  }
  response.setHeader(new Header(HttpConstants.HEADER_CONTENT_TYPE, parse(contentType, message)));
}

相关文章