Skip to content

Commit

Permalink
add relative to URL, and make all headers Uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
MMasterson committed May 5, 2020
1 parent 3ac9418 commit 4d5ba5d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Example/TUSKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/* Begin PBXFileReference section */
178E27EB1EA228D2A68B13FE /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
20578BE9B2C33456E6BC8985 /* TUSKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TUSKit.podspec; path = ../TUSKit.podspec; sourceTree = "<group>"; };
20578BE9B2C33456E6BC8985 /* TUSKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TUSKit.podspec; path = ../TUSKit.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
40C0ABED9802BD92047C4052 /* Pods-TUSKit_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TUSKit_Tests.debug.xcconfig"; path = "Target Support Files/Pods-TUSKit_Tests/Pods-TUSKit_Tests.debug.xcconfig"; sourceTree = "<group>"; };
607FACD01AFB9204008FA782 /* TUSKit_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TUSKit_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down
2 changes: 1 addition & 1 deletion TUSKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'TUSKit'
s.version = '2.0.1.alpha'
s.version = '2.0.2.alpha'
s.summary = 'A rewrite of TUSKit, in Swift'
s.swift_version = '5.0'

Expand Down
21 changes: 21 additions & 0 deletions TUSKit/Classes/HTTPURLResponse+allHeadersUpper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// HTTPURLResponse+allHeadersUpper.swift
// TUSKit
//
// Created by Mark Robert Masterson on 5/5/20.
//

import Foundation

extension HTTPURLResponse {

func allHeaderFieldsUpper() -> Dictionary<String, String> {
var newHeaders = Dictionary<String, String>()
for item in self.allHeaderFields {
let key = item.key as! String
newHeaders[key.uppercased()] = (item.value as! String)
}
return newHeaders
}

}
5 changes: 3 additions & 2 deletions TUSKit/Classes/TUSExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TUSExecutor: NSObject, URLSessionDelegate {
// Set the new status and other props for the upload
upload.status = .created
// upload.contentLength = httpResponse.allHeaderFields["Content-Length"] as? String
upload.uploadLocationURL = URL(string: httpResponse.allHeaderFields["Location"] as! String)
upload.uploadLocationURL = URL(string: httpResponse.allHeaderFieldsUpper()["LOCATION"]!, relativeTo: TUSClient.shared.uploadURL)
//Begin the upload
self.upload(forUpload: upload)
}
Expand Down Expand Up @@ -79,7 +79,8 @@ class TUSExecutor: NSObject, URLSessionDelegate {
case 200..<300:
//success
if (chunks.count > position+1 ){
upload.uploadOffset = httpResponse.allHeaderFields["upload-offset"] as! String

upload.uploadOffset = httpResponse.allHeaderFieldsUpper()["UPLOAD-OFFSET"]
self.upload(forChunks: chunks, withUpload: upload, atPosition: position+1)
} else
if (httpResponse.statusCode == 204) {
Expand Down

0 comments on commit 4d5ba5d

Please sign in to comment.