src/java/org/apache/nutch/tools/warc/WARCExporter.java [306:341]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              .append(CRLF);

          contentLength = payload.toString().getBytes("UTF-8").length;
          buffer.append("Content-Length").append(": ")
              .append(Integer.toString(contentLength)).append(CRLF);

          try {
            String normalised = key.toString().replaceAll(" ", "%20");
            URI uri = URI.create(normalised);
            buffer.append("WARC-Target-URI").append(": ")
                .append(uri.toASCIIString()).append(CRLF);
          } catch (Exception e) {
            LOG.error("Invalid URI {} ", key);
            context.getCounter("WARCExporter", "invalid URI").increment(1);
            return;
          }

          bos = new ByteArrayOutputStream();
          bos.write(buffer.toString().getBytes("UTF-8"));
          bos.write(CRLF_BYTES); // separate header and payload
          bos.write(payload.toString().getBytes("UTF-8"));
          bos.write(CRLF_BYTES);
          bos.write(CRLF_BYTES); // separation between records

          try {
            DataInput in = new DataInputStream(
                new ByteArrayInputStream(bos.toByteArray()));
            WARCRecord record = new WARCRecord(in);
            context.write(NullWritable.get(), new WARCWritable(record));
            context.getCounter("WARCExporter", "records generated")
                .increment(1);
          } catch (IOException | IllegalStateException exception) {
            LOG.error(
                "Exception when generating WARC metadata record for {} : {}",
                key, exception.getMessage(), exception);
            context.getCounter("WARCExporter", "exception").increment(1);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/java/org/apache/nutch/tools/warc/WARCExporter.java [366:401]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              .append(CRLF);

          contentLength = payload.toString().getBytes("UTF-8").length;
          buffer.append("Content-Length").append(": ")
              .append(Integer.toString(contentLength)).append(CRLF);

          try {
            String normalised = key.toString().replaceAll(" ", "%20");
            URI uri = URI.create(normalised);
            buffer.append("WARC-Target-URI").append(": ")
                .append(uri.toASCIIString()).append(CRLF);
          } catch (Exception e) {
            LOG.error("Invalid URI {} ", key);
            context.getCounter("WARCExporter", "invalid URI").increment(1);
            return;
          }

          bos = new ByteArrayOutputStream();
          bos.write(buffer.toString().getBytes("UTF-8"));
          bos.write(CRLF_BYTES); // separate header and payload
          bos.write(payload.toString().getBytes("UTF-8"));
          bos.write(CRLF_BYTES);
          bos.write(CRLF_BYTES); // separation between records

          try {
            DataInput in = new DataInputStream(
                new ByteArrayInputStream(bos.toByteArray()));
            WARCRecord record = new WARCRecord(in);
            context.write(NullWritable.get(), new WARCWritable(record));
            context.getCounter("WARCExporter", "records generated")
                .increment(1);
          } catch (IOException | IllegalStateException exception) {
            LOG.error(
                "Exception when generating WARC metadata record for {} : {}",
                key, exception.getMessage(), exception);
            context.getCounter("WARCExporter", "exception").increment(1);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



