Skip to content

Commit 29eae7a

Browse files
author
Pushkar N Kulkarni
authored
Merge pull request #693 from saiHemak/nsurlsession-bug
[URLSession] Data, response not returned when headers are set [SR-2983]
2 parents 6fce109 + ab3ed81 commit 29eae7a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Foundation/NSURLSession/HTTPMessage.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,13 @@ private extension URLSessionTask._HTTPMessage._Header {
292292
var value: String?
293293
let line = headView[headView.index(after: nameRange.upperBound)..<headView.endIndex]
294294
if !line.isEmpty {
295-
guard let v = line.trimSPHTPrefix else { return nil }
296-
value = String(v)
295+
if line.hasSPHTPrefix && line.count == 1 {
296+
// to handle empty headers i.e header without value
297+
value = String("")
298+
} else {
299+
guard let v = line.trimSPHTPrefix else { return nil }
300+
value = String(v)
301+
}
297302
}
298303
do {
299304
var t = tail

0 commit comments

Comments
 (0)