本文整理了Java中org.apache.http.HttpRequest.setHeaders()
方法的一些代码示例,展示了HttpRequest.setHeaders()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.setHeaders()
方法的具体详情如下:
包路径:org.apache.http.HttpRequest
类名称:HttpRequest
方法名:setHeaders
暂无
代码示例来源:origin: soabase/soabase
@Override
public void setHeaders(Header[] headers)
{
implementation.setHeaders(headers);
}
代码示例来源:origin: org.apache.axis2/axis2-transport-http
public void setHeaders(Header[] headers) {
this.request.setHeaders(headers);
}
代码示例来源:origin: apache/axis2-java
public void setHeaders(Header[] headers) {
this.request.setHeaders(headers);
}
代码示例来源:origin: stackoverflow.com
public static HttpRequestFactory createRequestFactory(final HttpTransport transport) {
return transport.createRequestFactory(new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
GoogleHeaders headers = new GoogleHeaders();
headers.setApplicationName("MyFirstLocationApp");
request.setHeaders(headers);
JsonHttpParser parser = new JsonHttpParser(new JacksonFactory());
request.addParser(parser);
}
});
}
代码示例来源:origin: stackoverflow.com
public boolean setdData(Context context, String filePath, String userId, String albumId, String accessToken) {
boolean success = false;
Bitmap bitmap = BitmapFactory.decodeFile(filePath);
if (bitmap != null) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, baos);
byte[] data = baos.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
HttpRequestFactory requestFactory = new NetHttpTransport().createRequestFactory();
InputStreamContent content = new InputStreamContent("image/jpeg", inputStream);
HttpRequest request = requestFactory.buildPostRequest(new genericUrl("https://picasaweb.google.com/data/feed/api/user/"+userId+"/"+albumId+"/default"), content);
GoogleHeaders headers = new GoogleHeaders();
String fileName = "Whatever...";
headers.setSlugFromFileName(fileName);
headers.setAuthorization("OAuth " + accessToken);
request.setHeaders(headers);
request.execute().ignore();
// Success!
success = true
} catch (IOException e) {
}
}
return success;
}
代码示例来源:origin: stackoverflow.com
String placeJSON =
"{"+
"\"location\": {" +
"\"lat\": " + latitude + "," +
"\"lng\": " + longitude +
"}," +
"\"accuracy\":" + accuracy + "," +
"\"name\": \"" + name + "\"," +
"\"types\": [\"" + type + "\"]," +
"\"language\": \"en\" " +
"}";
HttpRequest request;
request = t.buildPostRequest(new GenericUrl(PLACES_ADD_URL), ByteArrayContent.fromString(null, placeJSON));
//Set the Google headers
GoogleHeaders headers = new GoogleHeaders();
headers.setContentType("application/json");
request.setHeaders(headers);
request.getUrl().put("key", "....");
request.getUrl().put("sensor", "true");
request.execute();
代码示例来源:origin: stackoverflow.com
HttpTransport httpTransport = new NetHttpTransport();
HttpRequestFactory httpRequestFactory = httpTransport.createRequestFactory();
String data = "query=" + query;
HttpContent content = new ByteArrayContent("application/x-www-form-urlencoded", data.getBytes());
GenericUrl url = new GenericUrl("https://www.googleapis.com/freebase/v1/mqlread");
HttpRequest request = httpRequestFactory.buildPostRequest(url, content);
HttpHeaders headers = new HttpHeaders();
headers.put("X-HTTP-Method-Override","GET");
request.setHeaders(headers);
HttpResponse response = request.execute();
代码示例来源:origin: org.springframework.cloud/spring-cloud-netflix-zuul
httpRequest.setHeaders(convertHeaders(headers));
return httpRequest;
代码示例来源:origin: vc.inreach.aws/aws-signing-request-interceptor
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
request.setHeaders(headers(signer.getSignedHeaders(
path(request),
request.getRequestLine().getMethod(),
params(request),
headers(request),
body(request))
));
}
代码示例来源:origin: stackoverflow.com
headers.setContentRange("bytes " + (length == 0 ? "*" : offset + "-" + (limit - 1)) + (isFinalChunk ? "/" + limit : "/*"));
req.setHeaders(headers);
代码示例来源:origin: inreachventures/aws-signing-request-interceptor
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
request.setHeaders(headers(signer.getSignedHeaders(
path(request),
request.getRequestLine().getMethod(),
params(request),
headers(request),
body(request))
));
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.clients
request.setHeaders(headers.toArray(new Header[headers.size()]));
代码示例来源:origin: stackoverflow.com
private String initiateResumableUpload() throws IOException {
String URI = "https://storage.googleapis.com/" + bucket + "/" + path;
GenericUrl url = new GenericUrl(URI);
HttpRequest req = requestFactory.buildPostRequest(url, new ByteArrayContent("text/plain", new byte[0]));
HttpHeaders headers = new HttpHeaders();
headers.set("x-goog-resumable", "start");
headers.setContentLength((long) 0);
headers.setContentType("text/plain");
req.setHeaders(headers);
req.setReadTimeout((int) DEFAULT_TIMEOUT);
req.setResponseHeaders(headers);
HttpResponse resp;
try {
resp = req.execute();
} catch (IOException e) {
throw e;
}
if (resp.getStatusCode() == 201) {
String location = resp.getHeaders().getLocation();
return location;
} else {
throw new IOException();
}
}
代码示例来源:origin: com.bugvm/bugvm-rt
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
代码示例来源:origin: org.apache.httpcomponents/httpclient-android
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
代码示例来源:origin: ibinti/bugvm
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
代码示例来源:origin: com.hynnet/httpclient
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
代码示例来源:origin: Nextdoor/bender
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
内容来源于网络,如有侵权,请联系作者删除!