本文整理了Java中org.apache.commons.httpclient.Header.getValue()
方法的一些代码示例,展示了Header.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header.getValue()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.Header
类名称:Header
方法名:getValue
[英]Returns an array of HeaderElements constructed from my value.
[中]返回由my值构造的HeaderElements数组。
代码示例来源: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
/**
* Returns an array of {@link HeaderElement}s
* constructed from my value.
*
* @see HeaderElement#parseElements(String)
*
* @return an array of header elements
*
* @since 3.0
*/
public HeaderElement[] getElements() {
return HeaderElement.parseElements(getValue());
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Returns an array of {@link HeaderElement}s
* constructed from my value.
*
* @see HeaderElement#parse
* @throws HttpException if the header cannot be parsed
* @return an array of header elements
*
* @deprecated Use #getElements
*/
public HeaderElement[] getValues() throws HttpException {
return HeaderElement.parse(getValue());
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Extracts a map of challenges ordered by authentication scheme name
*
* @param headers the array of authorization challenges
* @return a map of authorization challenges
*
* @throws MalformedChallengeException if any of challenge strings
* is malformed
*
* @since 3.0
*/
public static Map parseChallenges(final Header[] headers)
throws MalformedChallengeException {
if (headers == null) {
throw new IllegalArgumentException("Array of challenges may not be null");
}
String challenge = null;
Map challengemap = new HashMap(headers.length);
for (int i = 0; i < headers.length; i++) {
challenge = headers[i].getValue();
String s = AuthChallengeParser.extractScheme(challenge);
challengemap.put(s, challenge);
}
return challengemap;
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* <p>
* This implementation will parse the <tt>Allow</tt> header to obtain
* the set of methods supported by the resource identified by the Request-URI.
* </p>
*
* @param state the {@link HttpState state} information associated with this method
* @param conn the {@link HttpConnection connection} used to execute
* this HTTP method
*
* @see #readResponse
* @see #readResponseHeaders
* @since 2.0
*/
protected void processResponseHeaders(HttpState state, HttpConnection conn) {
LOG.trace("enter OptionsMethod.processResponseHeaders(HttpState, HttpConnection)");
Header allowHeader = getResponseHeader("allow");
if (allowHeader != null) {
String allowHeaderValue = allowHeader.getValue();
StringTokenizer tokenizer =
new StringTokenizer(allowHeaderValue, ",");
while (tokenizer.hasMoreElements()) {
String methodAllowed =
tokenizer.nextToken().trim().toUpperCase();
methodsAllowed.addElement(methodAllowed);
}
}
}
代码示例来源: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
/**
* 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
throw new IllegalArgumentException("Header may not be null.");
return parse(host, port, path, secure, header.getValue());
代码示例来源:origin: commons-httpclient/commons-httpclient
Header header = headers[i];
try {
return Long.parseLong(header.getValue());
} catch (NumberFormatException e) {
if (LOG.isWarnEnabled()) {
代码示例来源:origin: commons-httpclient/commons-httpclient
Map challengemap = new HashMap(challenges.length);
for (int i = 0; i < challenges.length; i++) {
challenge = challenges[i].getValue();
String s = AuthChallengeParser.extractScheme(challenge);
challengemap.put(s, challenge);
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Return the header field at the specified position
* @param position The position
* @return The header field.
* @see java.net.HttpURLConnection#getHeaderField(int)
* @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders()
*/
public String getHeaderField(int position) {
LOG.trace("enter HttpURLConnection.getHeaderField(int)");
// Note: HttpClient does not consider the returned Status Line as
// a response header. However, getHeaderField(0) is supposed to
// return the status line. Hence the special case below ...
if (position == 0) {
return this.method.getStatusLine().toString();
}
// 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 (position < 0 || position > headers.length) {
return null;
}
return headers[position - 1].getValue();
}
代码示例来源:origin: commons-httpclient/commons-httpclient
if (connectionHeader.getValue().equalsIgnoreCase("close")) {
if (LOG.isDebugEnabled()) {
LOG.debug("Should close connection in response to directive: "
+ connectionHeader.getValue());
} else if (connectionHeader.getValue().equalsIgnoreCase("keep-alive")) {
if (LOG.isDebugEnabled()) {
LOG.debug("Should NOT close connection in response to directive: "
+ connectionHeader.getValue());
代码示例来源:origin: apache/incubator-pinot
String redirectedReqString = firstPutReq.getResponseHeader(LOCATION).getValue();
PutMethod redirectedReq = new PutMethod(redirectedReqString);
File localFile = new File(localFilePath);
代码示例来源:origin: commons-httpclient/commons-httpclient
return parse(host, port, path, secure, header.getValue());
} else if (header.getName().equalsIgnoreCase(RFC2109Spec.SET_COOKIE_KEY)) {
return this.rfc2109.parse(host, port, path, secure, header.getValue());
} else {
throw new MalformedCookieException("Header name is not valid. " +
代码示例来源:origin: apache/incubator-gobblin
throw new SchemaRegistryException(
"Error reading schema id returned by registerSchema call: headers.length = " + headers.length);
} else if (!headers[0].getValue().startsWith(SCHEMA_ID_HEADER_PREFIX)) {
throw new SchemaRegistryException(
"Error parsing schema id returned by registerSchema call: header = " + headers[0].getValue());
} else {
LOG.info("Registered schema successfully");
schemaKey = headers[0].getValue().substring(SCHEMA_ID_HEADER_PREFIX.length());
代码示例来源:origin: apache/incubator-gobblin
throw new SchemaRegistryException(
"Error reading schema id returned by registerSchema call: headers.length = " + headers.length);
} else if (!headers[0].getValue().startsWith(SCHEMA_ID_HEADER_PREFIX)) {
throw new SchemaRegistryException(
"Error parsing schema id returned by registerSchema call: header = " + headers[0].getValue());
} else {
LOG.info("Registered schema successfully");
schemaKey = headers[0].getValue().substring(SCHEMA_ID_HEADER_PREFIX.length());
代码示例来源:origin: commons-httpclient/commons-httpclient
if (connectionHeader.getValue().equalsIgnoreCase("close")) {
if (LOG.isWarnEnabled()) {
LOG.warn("Invalid header encountered '" + connectionHeader.toExternalForm()
代码示例来源:origin: commons-httpclient/commons-httpclient
if (LOG.isWarnEnabled()) {
LOG.warn("Invalid cookie header: \""
+ header.getValue()
+ "\". " + e.getMessage());
代码示例来源:origin: commons-httpclient/commons-httpclient
String transferEncoding = transferEncodingHeader.getValue();
if (!"chunked".equalsIgnoreCase(transferEncoding)
&& !"identity".equalsIgnoreCase(transferEncoding)) {
String connectionDirective = null;
if (connectionHeader != null) {
connectionDirective = connectionHeader.getValue();
代码示例来源:origin: commons-httpclient/commons-httpclient
return false;
String location = locationHeader.getValue();
if (LOG.isDebugEnabled()) {
LOG.debug("Redirect requested to location '" + location + "'");
内容来源于网络,如有侵权,请联系作者删除!