Package org.apache.shindig.gadgets.http

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


          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");
    }

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

    if (request.getParameter(Param.GADGET.getKey()) != null) {
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

      // 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

    List<Map.Entry<String, String>> entryList = OAuthRequest.selectOAuthParams(message);

    switch (paramLocationEnum) {
      case AUTH_HEADER:
        request.addHeader("Authorization", OAuthRequest.getAuthorizationHeader(entryList));
        break;

      case POST_BODY:
        if (!OAuth.isFormEncoded(contentType)) {
          throw new RuntimeException(
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

        Enumeration<?> headerValues = servletReq.getHeaders(headerName);
        while (headerValues.hasMoreElements()) {
          obj = headerValues.nextElement();
          if (obj instanceof String) {
            req.addHeader(headerName, (String) obj);
          }
        }
      }
    }
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

      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

    origRequest.addAllHeaders(addedHeaders);

    HttpRequest req = new HttpRequest(Uri.parse(
        "http://www.example.org/data.html"));
    req.removeHeader(HttpRequest.DOS_PREVENTION_HEADER);
    req.addHeader("h1", "hello");
    req.addHeader("Content-Length", "10");
    req.addHeader("unchanged_header", "original_value");

    UriUtils.copyRequestHeaders(origRequest, req,
        UriUtils.DisallowedHeaders.POST_INCOMPATIBLE_DIRECTIVES);
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.