private String getKernelId()

in src/org/jetbrains/plugins/ipnb/protocol/IpnbConnection.java [260:287]


  private String getKernelId(byte[] postData) throws IOException {
    final URLConnection connection = new URL(createApiUrl(SESSIONS_PATH)).openConnection();
    if (connection instanceof HttpsURLConnection) {
      final HttpsURLConnection httpsConnection =
        ObjectUtils.tryCast(configureConnection((HttpURLConnection)connection, HTTPMethod.POST.name()),
                            HttpsURLConnection.class);
      if (httpsConnection != null) {
        httpsConnection.setRequestProperty(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType());
        httpsConnection.setRequestProperty(HttpHeaders.CONTENT_LENGTH, Integer.toString(postData.length));
        httpsConnection.setUseCaches(false);
        httpsConnection.setDoOutput(true);

        final OutputStream outputStream = connection.getOutputStream();
        try (DataOutputStream wr = new DataOutputStream(outputStream)) {
          wr.write(postData);
          wr.flush();
        }
        httpsConnection.connect();
        if (httpsConnection.getResponseCode() == HttpURLConnection.HTTP_CREATED) {
          final String response = getResponse(httpsConnection);
          final OldFormatSessionWrapper wrapper = new GsonBuilder().create().fromJson(response, OldFormatSessionWrapper.class);
          return wrapper.kernel.id;
        }
        httpsConnection.disconnect();
      }
    }
    return null;
  }