mirror of https://github.com/zlatinb/muwire
reuse header parsing code
parent
8f923ec06e
commit
e5815bed88
|
@ -150,16 +150,7 @@ class DownloadSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse all headers
|
// parse all headers
|
||||||
Map<String,String> headers = new HashMap<>()
|
Map<String,String> headers = DataUtil.readAllHeaders(is)
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
|
||||||
// prase X-Alt if present
|
// prase X-Alt if present
|
||||||
if (headers.containsKey("X-Alt")) {
|
if (headers.containsKey("X-Alt")) {
|
||||||
|
|
Loading…
Reference in New Issue