reuse header parsing code

pull/53/head
Zlatin Balevsky 2020-10-11 15:34:16 +01:00
parent 8f923ec06e
commit e5815bed88
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 1 additions and 10 deletions

View File

@ -150,16 +150,7 @@ class DownloadSession {
}
// parse all headers
Map<String,String> 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<String,String> headers = DataUtil.readAllHeaders(is)
// prase X-Alt if present
if (headers.containsKey("X-Alt")) {