code: private static WebResource.Builder ensureJsonHeaders(MultivaluedMap<String, String> headers, WebResource.Builder requestBuilder, boolean contentType, boolean accept) {
          boolean hasContentType = false;
          boolean hasAccept = false;
          if (headers != null) {
              for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
                  String key = entry.getKey();
                  for (String val : entry.getValue()) {
                      if (contentType && HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(key)) {
                          hasContentType = true;
                      } else if (accept && HttpHeaders.ACCEPT.equalsIgnoreCase(key)) {
                          hasAccept = true;
                      }
                      requestBuilder = requestBuilder.header(key, val);
                  }
              }
          }
          if (!hasContentType) {
              requestBuilder = requestBuilder.type(MediaType.APPLICATION_JSON);
          }
          if (!hasAccept) {
              requestBuilder = requestBuilder.accept(MediaType.APPLICATION_JSON);
          }
          return requestBuilder;
      }
docs: Adds the specified headers to the request builder. Provides default
  headers for JSON objects requests and submissions.
  
  @param headers the headers to add.
  @param requestBuilder the request builder. Cannot be <code>null</code>.
  @param contentType <code>true</code> to add a default Content Type header
  if no Content Type header is provided.
  @param accept <code>true</code> to add a default Accepts header if no
  Accepts header is provided.
  @return the resulting request builder. Guaranteed not <code>null</code>.