Package org.apache.shindig.gadgets.http

Examples of org.apache.shindig.gadgets.http.HttpRequest.addHeader()


    String data = "<html><body>Moved to new page</body></html>";
    String redirectLocation = "http://example-redirected.org/data.html";

    ((FakeCaptureRewriter) rewriter).setContentToRewrite(data);
    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());
    HttpResponse resp = new HttpResponseBuilder()
        .setResponse(data.getBytes())
        .setHeader("Content-Type", "text/html")
        .setHeader("Location", redirectLocation)
        .setHttpStatusCode(302)
View Full Code Here


    String url = "http://example.org/data.html";
    String data = "<html><body>This is error page</body></html>";

    ((FakeCaptureRewriter) rewriter).setContentToRewrite(REWRITE_CONTENT);
    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());
    HttpResponse resp = new HttpResponseBuilder()
        .setResponse(data.getBytes())
        .setHeader("Content-Type", "text/html")
        .setHttpStatusCode(404)
        .create();
View Full Code Here

    String url = "http://example.org/data.html";
    String data = "<html><body>This is error page</body></html>";

    ((FakeCaptureRewriter) rewriter).setContentToRewrite(data);
    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());
    HttpResponse resp = new HttpResponseBuilder()
        .setResponse(data.getBytes())
        .setHeader("Content-Type", "text/html")
        .setHttpStatusCode(500)
        .create();
View Full Code Here

    String url = "http://example.org/data.html";
    String data = "<html><body>This is error page</body></html>";

    ((FakeCaptureRewriter) rewriter).setContentToRewrite(data);
    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());
    HttpResponse resp = new HttpResponseBuilder()
        .setResponse(data.getBytes())
        .setHeader("Content-Type", "text/html")
        .setHttpStatusCode(5001)
        .create();
View Full Code Here

    String url = "http://example.org/data.html";
    String data = "<html><body>Hello World</body></html>";

    ((FakeCaptureRewriter) rewriter).setContentToRewrite(REWRITE_CONTENT);
    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());
    HttpResponse resp = new HttpResponseBuilder()
        .setResponse(data.getBytes())
        .setHeader("Content-Type", "text/html")
        .setHeader("Set-Cookie", "name=value")
        .setHeader("Set-Cookie2", "name2=value2")
View Full Code Here

    String url = "http://example.org/data.html";
    String data = "<html><body>Hello World</body></html>";

    ((FakeCaptureRewriter) rewriter).setContentToRewrite(REWRITE_CONTENT);
    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());

    Map<String, String> headersMap = Maps.newHashMap();
    headersMap.put("Set-Cookie", "name=value");
    headersMap.put("Set-Cookie2", "name2=value2");
    headersMap.put("Date", "Mon, 01 Jan 1970 00:00:00 GMT");
View Full Code Here

    String url = "http://example.org/data.html";
    String data = "<html><body>Hello World</body></html>";

    ((FakeCaptureRewriter) rewriter).setContentToRewrite(REWRITE_CONTENT);
    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());
    HttpResponse resp = new HttpResponseBuilder()
        .setResponse(data.getBytes())
        .setHeader("Content-Type", "text/html")
        .setHttpStatusCode(200)
        .create();
View Full Code Here

                                        accelUriManager, true));
    String url = "http://example.org/data.html";
    String data = "<html><body>Hello World</body></html>";

    HttpRequest req = new HttpRequest(Uri.parse(url));
    req.addHeader("Host", Uri.parse(url).getAuthority());
    HttpResponse resp = new HttpResponseBuilder()
        .setResponse(data.getBytes())
        .setHeader("Content-Type", "text/html")
        .setHttpStatusCode(200)
        .create();
View Full Code Here

          throw new GadgetException(GadgetException.Code.INVALID_PARAMETER,
                  "Malformed header param specified:" + header, HttpResponse.SC_BAD_REQUEST);
        }
        String headerName = Utf8UrlCoder.decode(parts[0]);
        if (!HttpRequestHandler.BAD_HEADERS.contains(headerName.toUpperCase())) {
          req.addHeader(headerName, Utf8UrlCoder.decode(parts[1]));
        }
      }
    }

    // Set the default content type for post requests when a content type is not specified
View Full Code Here

      }
    }

    // Set the default content type for post requests when a content type is not specified
    if ("POST".equals(req.getMethod()) && req.getHeader("Content-Type") == null) {
      req.addHeader("Content-Type", "application/x-www-form-urlencoded");
    } else if ("1".equals(getParameter(request, MULTI_PART_FORM_POST, null))) {
      // We need the entire header from the original request because it comes with a boundary value
      // we need to reuse.
      req.setHeader("Content-Type", request.getHeader("Content-Type"));
    }
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.