Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Fixed platform specific issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cipi1965 authored and dduan committed Apr 8, 2017
1 parent c7bc5d9 commit 16ca5f4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/Just/Just.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Foundation

#if os(Linux)
import Dispatch
#endif

// stolen from python-requests
let statusCodeDescriptions = [
Expand Down Expand Up @@ -97,7 +100,12 @@ public enum HTTPMethod: String {

extension URLResponse {
var HTTPHeaders: [String: String] {
#if os(Linux)
return (self as? HTTPURLResponse)?.allHeaderFields ?? [:]
#else
return (self as? HTTPURLResponse)?.allHeaderFields as? [String: String]
?? [:]
#endif
}
}

Expand Down Expand Up @@ -194,8 +202,13 @@ public final class HTTPResult : NSObject {
public lazy var cookies: [String: HTTPCookie] = {
let foundCookies: [HTTPCookie]
if let headers = self.response?.HTTPHeaders, let url = self.response?.url {
#if os(Linux)
foundCookies = HTTPCookie.cookies(withResponseHeaderFields: headers,
forURL: url) as [HTTPCookie]
#else
foundCookies = HTTPCookie.cookies(withResponseHeaderFields: headers,
for: url) as [HTTPCookie]
#endif
} else {
foundCookies = []
}
Expand Down

0 comments on commit 16ca5f4

Please sign in to comment.