Codota Logo
HTTPResponse
Code IndexAdd Codota to your IDE (free)

How to use
HTTPResponse
in
de.taimos.httputils

Best Java code snippets using de.taimos.httputils.HTTPResponse (Showing top 6 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: de.taimos/dvalin-test

/**
 * assert that the response has a 2XX status code
 *
 * @param res the response to check
 */
protected final void assertOK(HTTPResponse res) {
  Assert.assertTrue(String.format("Expected OK - was %s", res.getStatus()), res.isStatusOK());
}
origin: de.taimos/dvalin-daemon

  private String getAuthToken(String token) {
    if(token == null || token.isEmpty()) {
      return null;
    }
    String path = this.protocol + "://" + this.server + "/api/auth";
    String body = "{\"token\":\"" + token + "\"}";
    HTTPRequest httpRequest = WS.url(path).body(body).header("Content-Type", "application/json;charset=UTF-8");
    try (HTTPResponse response = httpRequest.put()) {
      int status = response.getStatus();
      if (200 <= status && 300 > status) {
        String responseAsString = response.getResponseAsString();
        if (responseAsString.startsWith("\"")) {
          responseAsString = responseAsString.substring(1);
        }
        if (responseAsString.endsWith("\"")) {
          responseAsString = responseAsString.substring(0, responseAsString.length() - 1);
        }
        return responseAsString;
      } else {
        this.logger.warn("Authentication with CloudConductor Server {} failed with status {}", this.server, status);
      }
    }
    return null;
  }
}
origin: de.taimos/dvalin-test

/**
 * assert that the response has the given status code
 *
 * @param res    the response to check
 * @param status the status to check against
 */
protected final void assertStatus(HTTPResponse res, Status status) {
  Assert.assertTrue(String.format("Expected %s - was %s", status.getStatusCode(), res.getStatus()), res.getStatus() == status.getStatusCode());
}
origin: de.taimos/dvalin-test

/**
 * reads the response to the given object using the default JSON ObjectMapper
 *
 * @param <T>   the target class
 * @param res   the response to convert
 * @param clazz the class of the target
 * @return the converted object
 * @throws RuntimeException if deserialization fails
 */
protected <T> T read(HTTPResponse res, Class<T> clazz) {
  try {
    return MapperFactory.createDefault().readValue(res.getResponse().getEntity().getContent(), clazz);
  } catch (IllegalStateException | IOException e) {
    throw new RuntimeException(e);
  }
}
origin: de.taimos/dvalin-jaxrs

private String createTicket(Ticket ticket) {
  final String json;
  try {
    json = MapperFactory.createDefault().writeValueAsString(ticket.toJsonMap());
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
  String url = "https://" + this.subdomain + ".zendesk.com/api/v2/tickets.json";
  HTTPRequest req = WS.url(url).authBasic(this.agentMail + "/token", this.agentToken).contentType(MediaType.APPLICATION_JSON).body(json);
  try (HTTPResponse post = req.post()) {
    if (post.getStatus() != 201) {
      throw new InternalServerErrorException();
    }
    return post.getResponseAsString();
  }
}
origin: de.taimos/dvalin-daemon

@Override
protected InputStream getStream() throws Exception {
  this.logger.info("Loading properties from: {}", this.getDescription());
  HTTPResponse res = this.getResponse();
  return res.getResponse().getEntity().getContent();
}
de.taimos.httputilsHTTPResponse

Most used methods

  • getStatus
  • getResponse
  • getResponseAsString
  • isStatusOK

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • getSystemService (Context)
  • Point (java.awt)
    A point representing a location in (x, y) coordinate space, specified in integer precision.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JLabel (javax.swing)
  • JTable (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now