本文整理了Java中org.apache.commons.httpclient.Header.getName()
方法的一些代码示例,展示了Header.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header.getName()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.Header
类名称:Header
方法名:getName
暂无
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Returns a {@link String} representation of the header.
*
* @return stringHEAD
*/
public String toExternalForm() {
return ((null == getName() ? "" : getName())
+ ": "
+ (null == getValue() ? "" : getValue())
+ "\r\n");
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Gets the first header with the given name.
*
* <p>Header name comparison is case insensitive.
*
* @param name the name of the header to get
* @return the first header or <code>null</code>
*/
public Header getFirstHeader(String name) {
for (Iterator headerIter = headers.iterator(); headerIter.hasNext();) {
Header header = (Header) headerIter.next();
if (header.getName().equalsIgnoreCase(name)) {
return header;
}
}
return null;
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Gets the last header with the given name.
*
* <p>Header name comparison is case insensitive.
*
* @param name the name of the header to get
* @return the last header or <code>null</code>
*/
public Header getLastHeader(String name) {
// start at the end of the list and work backwards
for (int i = headers.size() - 1; i >= 0; i--) {
Header header = (Header) headers.get(i);
if (header.getName().equalsIgnoreCase(name)) {
return header;
}
}
return null;
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Tests if headers with the given name are contained within this group.
*
* <p>Header name comparison is case insensitive.
*
* @param name the header name to test for
* @return <code>true</code> if at least one header with the name is
* contained, <code>false</code> otherwise
*/
public boolean containsHeader(String name) {
for (Iterator headerIter = headers.iterator(); headerIter.hasNext();) {
Header header = (Header) headerIter.next();
if (header.getName().equalsIgnoreCase(name)) {
return true;
}
}
return false;
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Gets all of the headers with the given name. The returned array
* maintains the relative order in which the headers were added.
*
* <p>Header name comparison is case insensitive.
*
* @param name the name of the header(s) to get
*
* @return an array of length >= 0
*/
public Header[] getHeaders(String name) {
ArrayList headersFound = new ArrayList();
for (Iterator headerIter = headers.iterator(); headerIter.hasNext();) {
Header header = (Header) headerIter.next();
if (header.getName().equalsIgnoreCase(name)) {
headersFound.add(header);
}
}
return (Header[]) headersFound.toArray(new Header[headersFound.size()]);
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Return the header field
* @param name the name of the header
* @return the header field.
* @see java.net.HttpURLConnection#getHeaderField(String)
* @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders()
*/
public String getHeaderField(String name) {
LOG.trace("enter HttpURLConnection.getHeaderField(String)");
// Note: Return the last matching header in the Header[] array, as in
// the JDK implementation.
Header[] headers = this.method.getResponseHeaders();
for (int i = headers.length - 1; i >= 0; i--) {
if (headers[i].getName().equalsIgnoreCase(name)) {
return headers[i].getValue();
}
}
return null;
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Return the header field key
* @param keyPosition The key position
* @return The header field key.
* @see java.net.HttpURLConnection#getHeaderFieldKey(int)
* @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders()
*/
public String getHeaderFieldKey(int keyPosition) {
LOG.trace("enter HttpURLConnection.getHeaderFieldKey(int)");
// Note: HttpClient does not consider the returned Status Line as
// a response header. However, getHeaderFieldKey(0) is supposed to
// return null. Hence the special case below ...
if (keyPosition == 0) {
return null;
}
// Note: HttpClient does not currently keep headers in the same order
// that they are read from the HTTP server.
Header[] headers = this.method.getResponseHeaders();
if (keyPosition < 0 || keyPosition > headers.length) {
return null;
}
return headers[keyPosition - 1].getName();
}
代码示例来源: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: commons-httpclient/commons-httpclient
throw new IllegalArgumentException("Header may not be null.");
if (header.getName() == null) {
throw new IllegalArgumentException("Header name may not be null.");
if (header.getName().equalsIgnoreCase(SET_COOKIE2_KEY)) {
} else if (header.getName().equalsIgnoreCase(RFC2109Spec.SET_COOKIE_KEY)) {
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Sets the specified request header, overwriting any previous value.
* Note that header-name matching is case insensitive.
*
* @param header the header
*/
public void setRequestHeader(Header header) {
Header[] headers = getRequestHeaderGroup().getHeaders(header.getName());
for (int i = 0; i < headers.length; i++) {
getRequestHeaderGroup().removeHeader(headers[i]);
}
getRequestHeaderGroup().addHeader(header);
}
代码示例来源:origin: mttkay/signpost
public Map<String, String> getAllHeaders() {
Header[] origHeaders = httpMethod.getRequestHeaders();
HashMap<String, String> headers = new HashMap<String, String>();
for (Header h : origHeaders) {
headers.put(h.getName(), h.getValue());
}
return headers;
}
代码示例来源:origin: foxinmy/weixin4j
@Override
public HttpHeaders getHeaders() {
if (headers == null) {
headers = new HttpHeaders();
Header[] headers = httpMethod.getResponseHeaders();
for (Header header : headers) {
this.headers.add(header.getName(), header.getValue());
}
}
return headers;
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Returns a {@link String} representation of the header.
*
* @return stringHEAD
*/
public String toExternalForm() {
return ((null == getName() ? "" : getName())
+ ": "
+ (null == getValue() ? "" : getValue())
+ "\r\n");
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Returns a {@link String} representation of the header.
*
* @return stringHEAD
*/
public String toExternalForm() {
return ((null == getName() ? "" : getName())
+ ": "
+ (null == getValue() ? "" : getValue())
+ "\r\n");
}
代码示例来源:origin: io.fabric8/gateway-servlet
/**
* Determines whether the passed-in header is a 'Set-Cookie' header.
*
* @param header the {@link Header} to check
* @return {@code true} if the header is a 'Set-Cookie' header, false otherwise.
*/
public static boolean isSetCookieHeader(final Header header) {
return header.getName().equalsIgnoreCase("Set-Cookie");
}
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Returns a {@link String} representation of the header.
*
* @return stringHEAD
*/
public String toExternalForm() {
return ((null == getName() ? "" : getName())
+ ": "
+ (null == getValue() ? "" : getValue())
+ "\r\n");
}
代码示例来源:origin: org.littleshoot/http-client
private static String headerString(final Header[] headers)
{
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < headers.length; i++)
{
sb.append(headers[i].getName());
sb.append(": ");
sb.append(headers[i].getValue());
sb.append("\n");
}
return sb.toString();
}
代码示例来源:origin: org.springframework.ws/spring-ws-core
@Override
public Iterator<String> getResponseHeaderNames() throws IOException {
Header[] headers = postMethod.getResponseHeaders();
String[] names = new String[headers.length];
for (int i = 0; i < headers.length; i++) {
names[i] = headers[i].getName();
}
return Arrays.asList(names).iterator();
}
代码示例来源:origin: org.apache.axis2/axis2-transport-http
protected void init() {
setHeaderMap(new HashMap());
for (int i = 0; i < headers.length; i++) {
getHeaderMap().put(headers[i].getName(), headers[i].getValue());
}
}
代码示例来源:origin: org.mule.transports/mule-transport-http
public void setHeader(final Header header)
{
if (header == null)
{
return;
}
removeHeaders(header.getName());
addHeader(header);
}
内容来源于网络,如有侵权,请联系作者删除!