Skip to content

Commit

Permalink
Revert "User Agent Header Added (#277)" (#306)
Browse files Browse the repository at this point in the history
This reverts commit aa4ffb2.
  • Loading branch information
cpg authored Jul 2, 2020
1 parent ead4c22 commit 1c71a76
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions AmahiAnywhere/AmahiAnywhere/Utils/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,12 @@ public class Network {

static let shared = Network()

//eg. iOS/10_1
func deviceVersion() -> String {
let currentDevice = UIDevice.current
return "\(currentDevice.systemName)/\(currentDevice.systemVersion)"
}
//eg. iPhone5,2
func deviceName() -> String {
var sysinfo = utsname()
uname(&sysinfo)
return String(bytes: Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)), encoding: .ascii)!.trimmingCharacters(in: .controlCharacters)
}
//eg. MyApp/1
func appNameAndVersion() -> String {
let dictionary = Bundle.main.infoDictionary!
let version = dictionary["CFBundleShortVersionString"] as! String
let name = dictionary["CFBundleName"] as! String
return "\(name)/\(version)"
}

private func getDefaultHeaders() -> HTTPHeaders {
return [
"Accept": "application/json" +
"\(appNameAndVersion()) \(deviceName()) \(deviceVersion())"
]
}

private func getDefaultHeaders() -> HTTPHeaders {
return [
"Accept": "application/json"
// TODO: Add User-Agent header
]
}

private func getFinalHeaders(_ headers: HTTPHeaders) -> HTTPHeaders {
var finalHeaders = getDefaultHeaders()
Expand Down

0 comments on commit 1c71a76

Please sign in to comment.