Skip to content

Commit

Permalink
Add capacity-related methods/property to HTTPManagerRequest.HTTPHeaders
Browse files Browse the repository at this point in the history
Fixes #66.
  • Loading branch information
lilyball committed Nov 28, 2019
1 parent c72a0b0 commit 5c9f15b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,10 @@ work by you shall be dual licensed as above, without any additional terms or con
* Fix the Obj-C `-setValue:forHeaderField:` and `-setValue:forDefaultHeaderField:` methods to take a nullable value ([#67][]).
* Add `HTTPManagerRetryBehavior.init(any:)` to combine multiple retry behaviors together ([#69][]).
* Declare support for Swift 4.2 in the podspec.
* Add `HTTPManagerRequest.HTTPHeaders` methods `init(minimumCapacity:`) and `reserveCapacity(_:)` and property `capacity` ([#66][]).

[#65]: https://github.com/postmates/PMHTTP/issues/65 "Obj-C convenience functions for requests with data"
[#66]: https://github.com/postmates/PMHTTP/issues/66 "Add HTTPManagerRequest.HTTPHeaders.init(minimumCapacity:) and .reserveCapacity(_:)"
[#67]: https://github.com/postmates/PMHTTP/issues/67 "Obj-C -[HTTPManagerRequest setValue:forHeaderField:] should take nullable value"
[#69]: https://github.com/postmates/PMHTTP/issues/69 "HTTPManagerRetryBehavior should support composition"

Expand Down
12 changes: 12 additions & 0 deletions Sources/HTTPManagerRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ extension HTTPManagerRequest {
}
}

public init(minimumCapacity: Int) {
dictionary = Dictionary(minimumCapacity: minimumCapacity)
}

public var description: String {
return String(describing: dictionary)
}
Expand Down Expand Up @@ -394,6 +398,10 @@ extension HTTPManagerRequest {
return dictionary.isEmpty
}

public var capacity: Int {
return dictionary.capacity
}

public var startIndex: Index {
return dictionary.startIndex
}
Expand All @@ -416,6 +424,10 @@ extension HTTPManagerRequest {
}
}

public mutating func reserveCapacity(_ minimumCapacity: Int) {
dictionary.reserveCapacity(minimumCapacity)
}

public func index(forKey key: String) -> Index? {
return dictionary.index(forKey: key)
}
Expand Down

0 comments on commit 5c9f15b

Please sign in to comment.