本文整理汇总了Java中org.apache.http.client.methods.HttpUriRequest.getAllHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java HttpUriRequest.getAllHeaders方法的具体用法?Java HttpUriRequest.getAllHeaders怎么用?Java HttpUriRequest.getAllHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.methods.HttpUriRequest
的用法示例。
在下文中一共展示了HttpUriRequest.getAllHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: if
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
private HttpResponse b0449щ0449щщ0449(HttpUriRequest httpUriRequest, Map map, int i) throws Exception {
URI uri = httpUriRequest.getURI();
String trim = uri.getHost() != null ? uri.getHost().trim() : "";
if (trim.length() > 0) {
httpUriRequest.setHeader("Host", trim);
}
if (map != null) {
for (Object next : map.entrySet()) {
if (((b04170417041704170417З + b0417ЗЗЗЗ0417) * b04170417041704170417З) % bЗ0417ЗЗЗ0417 != bЗЗЗЗЗ0417) {
b04170417041704170417З = 81;
bЗЗЗЗЗ0417 = 31;
}
Entry entry = (Entry) next;
httpUriRequest.setHeader((String) entry.getKey(), (String) entry.getValue());
}
}
Header[] allHeaders = httpUriRequest.getAllHeaders();
Log.d(b043D043Dнн043Dн, "request URI [" + httpUriRequest.getURI() + "]");
for (Object obj : allHeaders) {
Log.d(b043D043Dнн043Dн, "request header [" + obj.toString() + "]");
}
HttpConnectionParams.setSoTimeout(this.bнн043Dн043Dн.getParams(), i);
HttpResponse execute = this.bнн043Dн043Dн.execute(httpUriRequest);
if (execute != null) {
return execute;
}
throw new RuntimeException("Null response returned.");
}
示例2: removeGoogleAuthHeaders
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
private static void removeGoogleAuthHeaders(HttpUriRequest request) {
for (Header header : request.getAllHeaders()) {
if (header.getName().equalsIgnoreCase("Authorization") &&
header.getValue().startsWith(AUTHORIZATION_HEADER_PREFIX)) {
Log.i(LOG_TAG, "Removing header:" + header);
request.removeHeader(header);
}
}
}
示例3: debugHttpRequest
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
/**
* デバッグ用.
* @param req デバッグ出力するRequestオブジェクト
* @param body デバッグ出力するリクエストボディ
*/
private void debugHttpRequest(final HttpUriRequest req, final String body) {
log.debug(req.getURI());
if (log.isDebugEnabled()) {
log.debug("【Request】 " + req.getMethod() + " " + req.getURI());
Header[] headers = req.getAllHeaders();
for (int i = 0; i < headers.length; i++) {
log.debug("RequestHeader[" + headers[i].getName() + "] : " + headers[i].getValue());
}
log.debug("RequestBody: " + body);
}
}
示例4: toCurl
import org.apache.http.client.methods.HttpUriRequest; //导入方法依赖的package包/类
/**
* Generates a cURL command equivalent to the given request.
*/
private static String toCurl(HttpUriRequest request, boolean logAuthToken) throws IOException {
StringBuilder builder = new StringBuilder();
builder.append("curl ");
for (Header header: request.getAllHeaders()) {
if (!logAuthToken
&& (header.getName().equals("Authorization") ||
header.getName().equals("Cookie"))) {
continue;
}
builder.append("--header \"");
builder.append(header.toString().trim());
builder.append("\" ");
}
URI uri = request.getURI();
// If this is a wrapped request, use the URI from the original
// request instead. getURI() on the wrapper seems to return a
// relative URI. We want an absolute URI.
if (request instanceof RequestWrapper) {
HttpRequest original = ((RequestWrapper) request).getOriginal();
if (original instanceof HttpUriRequest) {
uri = ((HttpUriRequest) original).getURI();
}
}
builder.append("\"");
builder.append(uri);
builder.append("\"");
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntityEnclosingRequest entityRequest =
(HttpEntityEnclosingRequest) request;
HttpEntity entity = entityRequest.getEntity();
if (entity != null && entity.isRepeatable()) {
if (entity.getContentLength() < 1024) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
entity.writeTo(stream);
String entityString = stream.toString();
// TODO: Check the content type, too.
builder.append(" --data-ascii \"")
.append(entityString)
.append("\"");
} else {
builder.append(" [TOO MUCH DATA TO INCLUDE]");
}
}
}
return builder.toString();
}