Java Code Examples for javax.net.ssl.HttpsURLConnection#getRequestMethod()

The following examples show how to use javax.net.ssl.HttpsURLConnection#getRequestMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseLogger.java    From gateway-android-sdk with Apache License 2.0 6 votes vote down vote up
@Override
public void logRequest(HttpsURLConnection c, String data) {
    String log = "REQUEST: " + c.getRequestMethod() + " " + c.getURL().toString();

    if (data != null) {
        log += "\n-- Data: " + data;
    }

    // log request headers
    Map<String, List<String>> properties = c.getRequestProperties();
    Set<String> keys = properties.keySet();
    for (String key : keys) {
        List<String> values = properties.get(key);
        for (String value : values) {
            log += "\n-- " + key + ": " + value;
        }
    }

    String[] parts = log.split("\n");
    for (String part : parts) {
        logDebug(part);
    }
}
 
Example 2
Source File: HttpsUrlConnectionSigner.java    From oauth1-signer-java with MIT License 5 votes vote down vote up
public void sign(HttpsURLConnection req, String payload) {
  URI uri;
  try {
    uri = req.getURL().toURI();
  } catch (URISyntaxException e) {
    throw new IllegalArgumentException("The provided URL could not be converted to an URI representation", e);
  }
  String method = req.getRequestMethod();
  String authHeader = OAuth.getAuthorizationHeader(uri, method, payload, charset, consumerKey, signingKey);
  req.setRequestProperty(OAuth.AUTHORIZATION_HEADER_NAME, authHeader);
}