Package com.google.appengine.api.urlfetch

Examples of com.google.appengine.api.urlfetch.HTTPRequest.addHeader()


      for (Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
         if (!prohibitedHeaders.contains(header))
            gaeRequest.addHeader(new HTTPHeader(header, entry.getValue()));
      }
      gaeRequest.addHeader(new HTTPHeader(HttpHeaders.USER_AGENT, USER_AGENT));
      /**
       * byte [] content is replayable and the only content type supportable by GAE. As such, we
       * convert the original request content to a byte array.
       */
      if (request.getPayload() != null) {
View Full Code Here


  @Override
  public List<GcsBucket> listBuckets() throws GcsException {
    try {
      HTTPRequest request = ExtendedOauthRawGcsService.makeGetRequest();
      request.addHeader(new HTTPHeader("Accept-Encoding", "identity"));
      HTTPResponse response = ExtendedOauthRawGcsService.doRequest(request, urlFetchService);
      System.out.println("new String(response.getContent()) = " + new String(response.getContent()));
      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document document = builder.parse(new ByteArrayInputStream(response.getContent()));
      return Parser.parseBucketList(document);
View Full Code Here

  }

  static HTTPRequest copyRequest(HTTPRequest in) {
    HTTPRequest out = new HTTPRequest(in.getURL(), in.getMethod(), in.getFetchOptions());
    for (HTTPHeader h : in.getHeaders()) {
      out.addHeader(h);
    }
    out.setPayload(in.getPayload());
    return out;
  }
View Full Code Here

        // add the headers to the request
        if (options.containsKey("headers")) {
            @SuppressWarnings("unchecked") Map<String, String> headers = (Map<String, String>) options.get("headers");
            for (Entry<String, String> e : headers.entrySet()) {
                request.addHeader(new HTTPHeader(e.getKey(), e.getValue()));
            }
        }

        // add the payload
        if (options.containsKey("payload")) {
View Full Code Here

public class HttpRequestTest extends URLFetchTestBase {

    @Test
    public void testGetters() throws Exception {
        HTTPRequest request = new HTTPRequest(getFetchUrl(), HTTPMethod.PATCH, FetchOptions.Builder.withDefaults());
        request.addHeader(new HTTPHeader("foo", "bar"));
        request.setPayload("qwerty".getBytes());

        Assert.assertEquals(getFetchUrl(), request.getURL());
        Assert.assertEquals(HTTPMethod.PATCH, request.getMethod());
        Assert.assertNotNull(request.getFetchOptions());
View Full Code Here

      HTTPRequest gaeRequest = new HTTPRequest(url, HTTPMethod.valueOf(request.getMethod().toString()), options);

      for (Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
         if (!prohibitedHeaders.contains(header))
            gaeRequest.addHeader(new HTTPHeader(header, entry.getValue()));
      }
      gaeRequest.addHeader(new HTTPHeader(HttpHeaders.USER_AGENT, USER_AGENT));
      /**
       * byte [] content is replayable and the only content type supportable by GAE. As such, we
       * convert the original request content to a byte array.
View Full Code Here

      for (Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
         if (!prohibitedHeaders.contains(header))
            gaeRequest.addHeader(new HTTPHeader(header, entry.getValue()));
      }
      gaeRequest.addHeader(new HTTPHeader(HttpHeaders.USER_AGENT, USER_AGENT));
      /**
       * byte [] content is replayable and the only content type supportable by GAE. As such, we
       * convert the original request content to a byte array.
       */
      if (request.getPayload() != null) {
View Full Code Here

      HTTPRequest gaeRequest = new HTTPRequest(url, HTTPMethod.valueOf(request.getMethod().toString()), options);

      for (Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
         if (!prohibitedHeaders.contains(header))
            gaeRequest.addHeader(new HTTPHeader(header, entry.getValue()));
      }
      gaeRequest.addHeader(new HTTPHeader(HttpHeaders.USER_AGENT, USER_AGENT));
      /**
       * byte [] content is replayable and the only content type supportable by GAE. As such, we
       * convert the original request content to a byte array.
View Full Code Here

      for (Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
         if (!prohibitedHeaders.contains(header))
            gaeRequest.addHeader(new HTTPHeader(header, entry.getValue()));
      }
      gaeRequest.addHeader(new HTTPHeader(HttpHeaders.USER_AGENT, USER_AGENT));
      /**
       * byte [] content is replayable and the only content type supportable by GAE. As such, we
       * convert the original request content to a byte array.
       */
      if (request.getPayload() != null) {
View Full Code Here

  @Inject Metrics metrics;

  public void send(String from, String to, String body, String inReplyTo, String references) {
    try {
      HTTPRequest request = new HTTPRequest(new URL(SENDGRID_SEND_URL), HTTPMethod.POST);
      request.addHeader(new HTTPHeader(CONTENT_TYPE, FORM_UTF8_MIME));
      request.setPayload(encodeQuery(new ImmutableMap.Builder<String, String>()
          .put("api_user", apiUser)
          .put("api_key", apiKey)
          .put("to", to)
          .put("from", from)
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.