(warc) Minor code clean-up.

Remove redundant String$getBytes().  This is mainly an improvement in code consistency.
This commit is contained in:
Viktor Lofgren 2024-02-10 18:30:33 +01:00
parent ba26f6ce84
commit e66d0b7431
2 changed files with 5 additions and 8 deletions

View File

@ -14,11 +14,6 @@ class WarcDigestBuilder {
this.digest = MessageDigest.getInstance(digestAlgorithm);
}
public void update(String s) {
byte[] bytes = s.getBytes();
update(bytes, bytes.length);
}
public void update(byte[] bytes) {
update(bytes, bytes.length);
}

View File

@ -145,14 +145,16 @@ public class WarcRecorder implements AutoCloseable {
WarcDigestBuilder requestDigestBuilder = new WarcDigestBuilder();
String httpRequestString = WarcProtocolReconstructor.getHttpRequestString(response.request(), requestUri);
byte[] httpRequestString = WarcProtocolReconstructor
.getHttpRequestString(response.request(), requestUri)
.getBytes();
requestDigestBuilder.update(httpRequestString);
WarcRequest warcRequest = new WarcRequest.Builder(requestUri)
.blockDigest(requestDigestBuilder.build())
.date(date)
.body(MediaType.HTTP_REQUEST, httpRequestString.getBytes())
.body(MediaType.HTTP_REQUEST, httpRequestString)
.concurrentTo(warcResponse.id())
.build();
@ -322,7 +324,7 @@ public class WarcRecorder implements AutoCloseable {
}
}
private class ResponseDataBuffer {
private static class ResponseDataBuffer {
private final byte[] data;
private int length = 0;
private int pos = 0;