From e5815bed884af560a855da8e63d64571fe42c01a Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 11 Oct 2020 15:34:16 +0100 Subject: [PATCH] reuse header parsing code --- .../com/muwire/core/download/DownloadSession.groovy | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy b/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy index 34042424..ee4a6de7 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadSession.groovy @@ -150,16 +150,7 @@ class DownloadSession { } // parse all headers - Map headers = new HashMap<>() - String header - while((header = readTillRN(is)) != "" && headers.size() < Constants.MAX_HEADERS) { - int colon = header.indexOf(':') - if (colon == -1 || colon == header.length() - 1) - throw new IOException("invalid header $header") - String key = header.substring(0, colon) - String value = header.substring(colon + 1) - headers[key] = value.trim() - } + Map headers = DataUtil.readAllHeaders(is) // prase X-Alt if present if (headers.containsKey("X-Alt")) {