Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpGet.addHeader()


    HttpEntity entity = null;
    String toFetchURL = req.getUrl();
    try {
      get = new HttpGet(toFetchURL);
      //设置请求GZIP压缩,注意,前面必须设置GZIP解压缩处理
      get.addHeader("Accept-Encoding", "gzip");
      for (Iterator<Entry<String, String>> it = headers.entrySet().iterator(); it.hasNext();){
        Entry<String, String> entry = it.next();
        get.setHeader(entry.getKey(), entry.getValue());
      }
     
View Full Code Here


        if (MapUtils.isNotEmpty(definition.getHeaders())) {
            for (Map.Entry<String, String> entry : definition.getHeaders().entrySet()) {
                String effectiveValue = entry.getValue();
                effectiveValue = ActionPlaceholders.substituteNode(effectiveValue, nodeAddress);
                effectiveValue = ActionPlaceholders.substituteExecution(effectiveValue, scheduleExecutionId);
                request.addHeader(entry.getKey(), effectiveValue);
            }
        }

        return request;
    }
View Full Code Here

  for(int i = 0; i < 3; i++) {
  try {       
    HttpClient client = new DefaultHttpClient()
    HttpGet get = new HttpGet(url[i]);
    get.setHeader("Cookie", "user=kevin.lam92@gmail.com;auth=e3eeba822df43aaa86abe30bb320b082");
    get.addHeader("Accept", "application/xml");
    get.addHeader("Content-Type", "application/xml");
    HttpResponse responsePost;
    responsePost = client.execute(get);
    HttpEntity resEntity = responsePost.getEntity();
        if (resEntity != null)  {
View Full Code Here

  try {       
    HttpClient client = new DefaultHttpClient()
    HttpGet get = new HttpGet(url[i]);
    get.setHeader("Cookie", "user=kevin.lam92@gmail.com;auth=e3eeba822df43aaa86abe30bb320b082");
    get.addHeader("Accept", "application/xml");
    get.addHeader("Content-Type", "application/xml");
    HttpResponse responsePost;
    responsePost = client.execute(get);
    HttpEntity resEntity = responsePost.getEntity();
        if (resEntity != null)  {
          results[i] = resEntity.getContentLength();
View Full Code Here

  private void getRest(String rightside, JiraJSONResponse response)
    throws IOException, ResponseException {

    final HttpRequestBase method = new HttpGet(URLbase + rightside);
    method.addHeader("Accept", "application/json");

    try {
      HttpResponse httpResponse = httpClient.execute(method);
      int resultCode = httpResponse.getStatusLine().getStatusCode();
      if (resultCode != 200)
View Full Code Here

  private void getRest(String rightside, JiraJSONResponse response)
    throws IOException, ResponseException {

    final HttpRequestBase method = new HttpGet(URLbase + rightside);
    method.addHeader("Accept", "application/json");

    try {
      HttpResponse httpResponse = httpClient.execute(method);
      int resultCode = httpResponse.getStatusLine().getStatusCode();
      if (resultCode != 200)
View Full Code Here

        Date now = new Date();
        Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
        impl = new CachingHttpClient(mockBackend);
        HttpRequest req1 = new HttpGet("http://foo.example.com/");
        HttpRequest req2 = new HttpGet("http://foo.example.com/");
        req2.addHeader("If-Modified-Since", DateUtils.formatDate(now));
        HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
                HttpStatus.SC_OK, "OK");
        resp1.setEntity(HttpTestUtils.makeBody(128));
        resp1.setHeader("Content-Length", "128");
        resp1.setHeader("ETag", "\"etag\"");
View Full Code Here

        resp1.setHeader("Date", DateUtils.formatDate(new Date()));
        resp1.setHeader("Cache-Control", "public, max-age=3600");
        resp1.setHeader("Last-Modified", DateUtils.formatDate(new Date()));

        // The variant has been modified since this date
        req2.addHeader("If-Modified-Since", DateUtils
                        .formatDate(tenSecondsAgo));

        HttpResponse resp2 = HttpTestUtils.make200Response();

        expect(
View Full Code Here

        resp1.setHeader("Date", DateUtils.formatDate(new Date()));
        resp1.setHeader("Cache-Control", "public, max-age=3600");
        resp1.setHeader("Last-Modified", DateUtils.formatDate(new Date()));

        // invalid date (date in the future)
        req2.addHeader("If-Modified-Since", DateUtils
                .formatDate(tenSecondsAfter));

        expect(
                mockBackend.execute(isA(HttpHost.class),
                        isA(HttpRequest.class), (HttpContext)
View Full Code Here

    public void testReturns304ForIfNoneMatchHeaderIfRequestServedFromCache()
            throws Exception {
        impl = new CachingHttpClient(mockBackend);
        HttpRequest req1 = new HttpGet("http://foo.example.com/");
        HttpRequest req2 = new HttpGet("http://foo.example.com/");
        req2.addHeader("If-None-Match", "*");
        HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
                HttpStatus.SC_OK, "OK");
        resp1.setEntity(HttpTestUtils.makeBody(128));
        resp1.setHeader("Content-Length", "128");
        resp1.setHeader("ETag", "\"etag\"");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.