code: private void writeRecord( OutputStream out, 
                              HttpHeaders headers, 
                              byte[] contents) throws IOException
    {
      if ( contents == null ) 
        {
          headers.add(CONTENT_LENGTH, "0");
        }
      else
        {
          headers.add(CONTENT_LENGTH,String.valueOf(contents.length));
        }
      
      out.write(WARC_ID.getBytes(DEFAULT_ENCODING));
      out.write(CR);
      out.write(LF);
  
      // NOTE: HttpHeaders.write() method includes the trailing CRLF.
      //       So we don't need to write it out here.
      headers.write(out);
    
      if ( contents != null ) 
        {
          out.write( contents );
        }
  
      // Emit the 2 trailing CRLF sequences.
      out.write(CR);
      out.write(LF);
      out.write(CR);
      out.write(LF);
    }
docs: Write the headers and contents as a WARC record to the given
  output stream.
  
  WARC record format:
  <pre>warc-file = 1*warc-record
  warc-record = header CRLF block CRLF CRLF
  header = version warc-fields
  version = "WARC/0.18" CRLF
  warc-fields = *named-field CRLF
  block = *OCTET</pre>