Skip to content

Commit 6871f06

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 3fcf5e9 + 663b45c commit 6871f06

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ChatSecure/Classes/Controllers/FileTransferManager.swift

+15-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,21 @@ public class FileTransferManager: NSObject, OTRServerCapabilitiesDelegate {
291291
}
292292
return
293293
}
294-
self.sessionManager.upload(outData, to: slot.putURL, method: .put)
294+
295+
// Pick optional headers from the slot and filter out any not allowed by
296+
// XEP-0363 (https://xmpp.org/extensions/xep-0363.html#request)
297+
let allowedHeaders = ["authorization", "cookie", "expires"]
298+
var forwardedHeaders:HTTPHeaders = [:]
299+
for (headerName, headerValue) in slot.putHeaders {
300+
let name = headerName.replacingOccurrences(of: "\n", with: "").lowercased()
301+
if allowedHeaders.contains(name) {
302+
forwardedHeaders[name] = headerValue.replacingOccurrences(of: "\n", with: "")
303+
}
304+
}
305+
forwardedHeaders["Content-Type"] = contentType
306+
forwardedHeaders["Content-Length"] = "\(UInt(outData.count))"
307+
308+
self.sessionManager.upload(outData, to: slot.putURL, method: .put, headers: forwardedHeaders)
295309
.validate()
296310
.responseData(queue: self.callbackQueue) { response in
297311
switch response.result {

0 commit comments

Comments
 (0)