Package org.apache.http.client.methods

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


    assertEquals(SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());

    bookmark = new Bookmark();
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
View Full Code Here


    bookmark = new Bookmark();
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
        new TypeReference<Set<UnprocessableEntityException.Violation>>() {
View Full Code Here

    bookmark = new Bookmark();
    bookmark.setDescription("Google");
    bookmark.setLink("http: // google . com");
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
View Full Code Here

    bookmark.setDescription("Google");
    bookmark.setLink("http: // google . com");
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
    violations = mapper.readValue(response.getEntity().getContent(),
        new TypeReference<Set<UnprocessableEntityException.Violation>>() {
View Full Code Here

    bookmark.setId(Long.valueOf(123456789));
    bookmark.setDescription("Test");
    bookmark.setLink("http://test.com");
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_BAD_REQUEST, response.getStatusLine().getStatusCode());
View Full Code Here

    bookmark.setDescription("Test");
    bookmark.setLink("http://test.com");
    request = new HttpPut(url + "/bookmark/" + id);
    request.setEntity(createEntity(bookmark));
    request.addHeader("Content-Type", "application/json");
    request.addHeader("Authorization", BASIC_CREDENTIALS);
    response = client.execute(request);
    response.close();
    assertEquals(SC_BAD_REQUEST, response.getStatusLine().getStatusCode());

    destroySample(id);
View Full Code Here

   public void write(MarshalledEntry entry) {
      HttpPut put = new HttpPut(keyToUri(entry.getKey()));

      InternalMetadata metadata = entry.getMetadata();
      if (metadata != null && metadata.expiryTime() > -1) {
         put.addHeader(TIME_TO_LIVE_SECONDS, Long.toString(timeoutToSeconds(metadata.lifespan())));
         put.addHeader(MAX_IDLE_TIME_SECONDS, Long.toString(timeoutToSeconds(metadata.maxIdle())));
      }

      try {
         String contentType = metadataHelper.getContentType(entry);
View Full Code Here

      HttpPut put = new HttpPut(keyToUri(entry.getKey()));

      InternalMetadata metadata = entry.getMetadata();
      if (metadata != null && metadata.expiryTime() > -1) {
         put.addHeader(TIME_TO_LIVE_SECONDS, Long.toString(timeoutToSeconds(metadata.lifespan())));
         put.addHeader(MAX_IDLE_TIME_SECONDS, Long.toString(timeoutToSeconds(metadata.maxIdle())));
      }

      try {
         String contentType = metadataHelper.getContentType(entry);
         put.setEntity(new ByteArrayEntity(marshall(contentType, entry), ContentType.create(contentType)));
View Full Code Here

   public void write(MarshalledEntry entry) {
      HttpPut put = new HttpPut(keyToUri(entry.getKey()));

      InternalMetadata metadata = entry.getMetadata();
      if (metadata != null && metadata.expiryTime() > -1) {
         put.addHeader(TIME_TO_LIVE_SECONDS, Long.toString(timeoutToSeconds(metadata.lifespan())));
         put.addHeader(MAX_IDLE_TIME_SECONDS, Long.toString(timeoutToSeconds(metadata.maxIdle())));
      }

      try {
         String contentType = metadataHelper.getContentType(entry);
View Full Code Here

      HttpPut put = new HttpPut(keyToUri(entry.getKey()));

      InternalMetadata metadata = entry.getMetadata();
      if (metadata != null && metadata.expiryTime() > -1) {
         put.addHeader(TIME_TO_LIVE_SECONDS, Long.toString(timeoutToSeconds(metadata.lifespan())));
         put.addHeader(MAX_IDLE_TIME_SECONDS, Long.toString(timeoutToSeconds(metadata.maxIdle())));
      }

      try {
         String contentType = metadataHelper.getContentType(entry);
         put.setEntity(new ByteArrayEntity(marshall(contentType, entry), ContentType.create(contentType)));
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.