@@ -85,6 +85,7 @@ private void loadMoreRows() throws IOException {
8585 // preload http response and request headers
8686 capture .status ();
8787 capture .method ();
88+ capture .records ();
8889
8990 rows .add (capture );
9091 }
@@ -139,7 +140,7 @@ private void savePayload() throws IOException {
139140 WarcRecord record = freshReader .next ().orElseThrow (() -> new IOException ("No record found at position " + selectedRecord .position ()));
140141
141142 Optional <WarcPayload > payload = ((WarcCaptureRecord ) record ).payload ();
142- if (!payload .isPresent ()) {
143+ if (!( record instanceof WarcMetadata ) && ! payload .isPresent ()) {
143144 System .out .print ("\r \u001B [KNo payload for this record. [Press any key]" );
144145 System .out .flush ();
145146 int ignore = System .in .read ();
@@ -162,7 +163,7 @@ private void savePayload() throws IOException {
162163 if (filename == null ) return ;
163164 if (filename .isEmpty ()) filename = defaultFilename ;
164165
165- try (MessageBody body = payload .get ().body ();
166+ try (MessageBody body = record instanceof WarcMetadata ? record . body () : payload .get ().body ();
166167 FileChannel out = FileChannel .open (Paths .get (filename ), StandardOpenOption .CREATE , StandardOpenOption .WRITE , StandardOpenOption .TRUNCATE_EXISTING )) {
167168 ByteBuffer buffer = ByteBuffer .allocate (8192 );
168169 while (body .read (buffer ) != -1 ) {
@@ -217,17 +218,17 @@ private void openInEditor() throws IOException {
217218 WarcRecord record = freshReader .next ().get ();
218219
219220 Optional <WarcPayload > payload = ((WarcCaptureRecord ) record ).payload ();
220- if (!payload .isPresent ()) {
221+ if (!( record instanceof WarcMetadata ) &&! payload .isPresent ()) {
221222 System .out .print ("\r \u001B [KNo payload for this record. [Press any key]" );
222223 System .out .flush ();
223224 System .in .read ();
224225 return ;
225226 }
226227
227- String extension = getExtension (payload .get ().type ());
228+ String extension = getExtension (record instanceof WarcMetadata ? record . contentType () : payload .get ().type ());
228229 Path tempFile = Files .createTempFile ("jwarc-payload" , extension );
229230 try {
230- try (MessageBody body = payload .get ().body ();
231+ try (MessageBody body = record instanceof WarcMetadata ? record . body () : payload .get ().body ();
231232 FileChannel out = FileChannel .open (tempFile , StandardOpenOption .WRITE , StandardOpenOption .TRUNCATE_EXISTING )) {
232233 ByteBuffer buffer = ByteBuffer .allocate (8192 );
233234 while (body .read (buffer ) != -1 ) {
0 commit comments