/** * Construct a header to be prepended to the actual content. This implementation writes * {@code Content-Length} and {@code Content-Type} attributes according to the LSP specification. */ protected String getHeader(int contentLength) { StringBuilder headerBuilder = new StringBuilder(); appendHeader(headerBuilder, CONTENT_LENGTH_HEADER, contentLength).append(CRLF); if (!StandardCharsets.UTF_8.name().equals(encoding)) { appendHeader(headerBuilder, CONTENT_TYPE_HEADER, JSON_MIME_TYPE); headerBuilder.append("; charset=").append(encoding).append(CRLF); } headerBuilder.append(CRLF); return headerBuilder.toString(); }
/** * Construct a header to be prepended to the actual content. This implementation writes * {@code Content-Length} and {@code Content-Type} attributes according to the LSP specification. */ protected String getHeader(int contentLength) { StringBuilder headerBuilder = new StringBuilder(); appendHeader(headerBuilder, CONTENT_LENGTH_HEADER, contentLength).append(CRLF); if (!StandardCharsets.UTF_8.name().equals(encoding)) { appendHeader(headerBuilder, CONTENT_TYPE_HEADER, JSON_MIME_TYPE); headerBuilder.append("; charset=").append(encoding).append(CRLF); } headerBuilder.append(CRLF); return headerBuilder.toString(); }