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 6895e7f commit cab56a2
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 @@ -415,8 +415,10 @@ work by you shall be dual licensed as above, without any additional terms or con
* Add Obj-C convenience functions for creating upload requests with an `NSData` but no explicit `contentType` ([#65][]).
* 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][]).
* 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 cab56a2

Please sign in to comment.