Package org.apache.shindig.gadgets.http

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


      }
    }

    // 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.addHeader("Content-Type", request.getHeader("Content-Type"));
    }
View Full Code Here


    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.addHeader("Content-Type", request.getHeader("Content-Type"));
    }

    req.setIgnoreCache("1".equals(getParameter(request, Param.NO_CACHE.getKey(), null)));

View Full Code Here

      paramLocation = OAuthParamLocation.AUTH_HEADER;
    }

    switch (paramLocation) {
      case AUTH_HEADER:
        result.addHeader("Authorization", getAuthorizationHeader(oauthParams));
        break;

      case POST_BODY:
        String contentType = result.getHeader("Content-Type");
        if (!OAuth.isFormEncoded(contentType)) {
View Full Code Here

      // Copy over allowed headers
      for (Map.Entry<String, List<String>> header : httpApiRequest.headers.entrySet()) {
        if (!BAD_HEADERS.contains(header.getKey().trim().toUpperCase())) {
          for (String value : header.getValue()) {
            req.addHeader(header.getKey(), value);
          }
        }
      }

      // Extract the gadget URI from the request or the security token
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

      // Copy over allowed headers
      for (Map.Entry<String, List<String>> header : httpApiRequest.headers.entrySet()) {
        if (!BAD_HEADERS.contains(header.getKey().trim().toUpperCase())) {
          for (String value : header.getValue()) {
            req.addHeader(header.getKey(), value);
          }
        }
      }

      // Extract the gadget URI from the request or the security token
View Full Code Here

        Enumeration<?> headerValues = servletReq.getHeaders(headerName);
        while (headerValues.hasMoreElements()) {
          obj = headerValues.nextElement();
          if (obj instanceof String) {
            req.addHeader(headerName, (String) obj);
          }
        }
      }
    }
View Full Code Here

  @Test
  public void testHtmlAccelNoData() throws Exception {
    Uri url = Uri.parse("http://example.org/data.html");

    HttpRequest req = new HttpRequest(url);
    req.addHeader("Host", url.getAuthority());
    expect(pipeline.execute(req)).andReturn(null).once();
    expectRequest("", url.toString());
    replay();

    servlet.doGet(request, recorder);
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

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.