本文整理了Java中com.google.appengine.api.urlfetch.HTTPResponse.getHeadersUncombined()
方法的一些代码示例,展示了HTTPResponse.getHeadersUncombined()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTTPResponse.getHeadersUncombined()
方法的具体详情如下:
包路径:com.google.appengine.api.urlfetch.HTTPResponse
类名称:HTTPResponse
方法名:getHeadersUncombined
暂无
代码示例来源:origin: GoogleCloudPlatform/appengine-gcs-client
/** Gets all headers with the name {@code headerName}, case-insensitive. */
private static Iterable<HTTPHeader> getHeaders(HTTPResponse resp, String headerName) {
final String lowercaseHeaderName = headerName.toLowerCase();
return Iterables.filter(resp.getHeadersUncombined(), new Predicate<HTTPHeader>() {
@Override public boolean apply(HTTPHeader header) {
return header.getName().toLowerCase().equals(lowercaseHeaderName);
}
});
}
代码示例来源:origin: com.threewks.thundr/thundr-gae
private Map<String, List<String>> buildHeaderMap(HTTPResponse response) {
Map<String, List<String>> headers = new LinkedHashMap<String, List<String>>();
for (HTTPHeader header : response.getHeadersUncombined()) {
String key = header.getName();
String value = header.getValue();
List<String> values = headers.get(key);
if (values == null) {
values = new ArrayList<String>();
headers.put(key, values);
}
values.add(value);
}
return headers;
}
代码示例来源:origin: com.force.api/force-wsc
/** Gets the values of all headers with the name {@code headerName}. */
List<String> getHeaders(HTTPResponse resp, String headerName) {
List<String> b = new ArrayList<String>();
for (HTTPHeader h : resp.getHeadersUncombined()) {
if (headerName.equalsIgnoreCase(h.getName())) {
b.add(h.getValue());
}
}
return b;
}
代码示例来源:origin: forcedotcom/wsc
/** Gets the values of all headers with the name {@code headerName}. */
List<String> getHeaders(HTTPResponse resp, String headerName) {
List<String> b = new ArrayList<String>();
for (HTTPHeader h : resp.getHeadersUncombined()) {
if (headerName.equalsIgnoreCase(h.getName())) {
b.add(h.getValue());
}
}
return b;
}
代码示例来源:origin: GoogleCloudPlatform/appengine-gcs-client
static void appendResponse(HTTPResponse resp, StringBuilder b) {
byte[] content = resp.getContent();
b.append(resp.getResponseCode()).append(" with ").append(content == null ? 0 : content.length);
b.append(" bytes of content");
for (HTTPHeader h : resp.getHeadersUncombined()) {
b.append('\n').append(h.getName()).append(": ").append(h.getValue());
}
b.append('\n').append(content == null ? "" : new String(content, UTF_8)).append('\n');
}
代码示例来源:origin: com.force.api/force-wsc
String getHeader(HTTPResponse resp, String headerName) {
for (HTTPHeader h : resp.getHeadersUncombined()) {
if (headerName.equalsIgnoreCase(h.getName())) {
return h.getValue();
}
}
return null;
}
代码示例来源:origin: forcedotcom/wsc
String getHeader(HTTPResponse resp, String headerName) {
for (HTTPHeader h : resp.getHeadersUncombined()) {
if (headerName.equalsIgnoreCase(h.getName())) {
return h.getValue();
}
}
return null;
}
代码示例来源:origin: com.google.http-client/google-http-client-appengine
UrlFetchResponse(HTTPResponse fetchResponse) {
this.fetchResponse = fetchResponse;
for (HTTPHeader header : fetchResponse.getHeadersUncombined()) {
String name = header.getName();
String value = header.getValue();
if (name != null && value != null) {
headerNames.add(name);
headerValues.add(value);
if ("content-type".equalsIgnoreCase(name)) {
contentType = value;
} else if ("content-encoding".equalsIgnoreCase(name)) {
contentEncoding = value;
} else if ("content-length".equalsIgnoreCase(name)) {
try {
contentLength = Long.parseLong(value);
} catch (NumberFormatException e) {
// ignore
}
}
}
}
}
代码示例来源:origin: com.dropbox.core/dropbox-core-sdk
private static Response toRequestorResponse(HTTPResponse response) {
Map<String, List<String>> headers = new HashMap<String, List<String>>();
for (HTTPHeader header : response.getHeadersUncombined()) {
List<String> existing = headers.get(header.getName());
if (existing == null) {
existing = new ArrayList<String>();
headers.put(header.getName(), existing);
}
existing.add(header.getValue());
}
return new Response(response.getResponseCode(),
new ByteArrayInputStream(response.getContent()),
headers);
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
@Test
public void testHeaders() throws Exception {
URLFetchService service = URLFetchServiceFactory.getURLFetchService();
URL url = getFetchUrl();
HTTPRequest req = new HTTPRequest(url, HTTPMethod.POST);
req.setHeader(new HTTPHeader("Content-Type", "application/octet-stream"));
req.setPayload("Headers!".getBytes(UTF_8));
HTTPResponse response = service.fetch(req);
boolean found = false;
List<HTTPHeader> headers = response.getHeadersUncombined();
for (HTTPHeader h : headers) {
if (h.getName().equals("ABC")) {
Assert.assertEquals("123", h.getValue());
found = true;
break;
}
}
Assert.assertTrue("Cannot find matching header <ABC : 123>: " + headers, found);
found = false;
headers = response.getHeaders();
for (HTTPHeader h : headers) {
if (h.getName().equals("XYZ")) {
Assert.assertEquals("1, 2, 3", h.getValue());
found = true;
break;
}
}
Assert.assertTrue("Cannot find matching header <XYZ : 1,2,3>: " + headers, found);
}
内容来源于网络,如有侵权,请联系作者删除!