private void writeHttpMessage(RecordedHttpMessage recordedHttpMessage) throws IOException { if (!recordedHttpMessage.getHeaders().isEmpty()) { writeHttpHeaders(recordedHttpMessage.getHeaders()); } if (recordedHttpMessage.hasHttpBody()) { writeHttpBody(recordedHttpMessage.getHttpBody()); } }
public RecordedHttpMessage(Multimap<String, String> headers, RecordedHttpBody httpBody) { if (headers != null) { _headers = headers; } _httpBody = httpBody; // Update the Content-Length header if appropriate if (_headers.containsKey(HttpHeaders.CONTENT_LENGTH)) { try { int contentLength = _httpBody.getContent(getCharset()).length; _headers = LinkedHashMultimap.create(_headers); _headers.put(HttpHeaders.CONTENT_LENGTH, Integer.toString(contentLength)); } catch (IOException e) { logger.error("Caught exception " + e + " while updating Content-Length header"); } } }