Skip to content

Commit d9a9658

Browse files
committed
rename .fixed to .known
1 parent e140e5d commit d9a9658

File tree

8 files changed

+46
-46
lines changed

8 files changed

+46
-46
lines changed

Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest+Prepared.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ extension RequestBodyLength {
6363
init(_ body: HTTPClientRequest.Body?) {
6464
switch body?.mode {
6565
case .none:
66-
self = .fixed(0)
66+
self = .known(0)
6767
case .byteBuffer(let buffer):
68-
self = .fixed(buffer.readableBytes)
68+
self = .known(buffer.readableBytes)
6969
case .sequence(let length, _, _), .asyncSequence(let length, _):
7070
self = length
7171
}

Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extension HTTPClientRequest.Body {
6363
_ bytes: Bytes
6464
) -> Self where Bytes.Element == UInt8 {
6565
self.init(.sequence(
66-
length: .fixed(bytes.count),
66+
length: .known(bytes.count),
6767
canBeConsumedMultipleTimes: true
6868
) { allocator in
6969
if let buffer = bytes.withContiguousStorageIfAvailable({ allocator.buffer(bytes: $0) }) {
@@ -161,8 +161,8 @@ extension HTTPClientRequest.Body {
161161
/// size of the request body is not known before starting the request
162162
public static let unknown: Self = .init(storage: .unknown)
163163
/// size of the request body is fixed and exactly `count` bytes
164-
public static func fixed(_ count: Int) -> Self {
165-
.init(storage: .fixed(count))
164+
public static func known(_ count: Int) -> Self {
165+
.init(storage: .known(count))
166166
}
167167

168168
@usableFromInline

Sources/AsyncHTTPClient/ConnectionPool/RequestBodyLength.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ internal enum RequestBodyLength: Hashable {
1818
/// size of the request body is not known before starting the request
1919
case unknown
2020
/// size of the request body is fixed and exactly `count` bytes
21-
case fixed(_ count: Int)
21+
case known(_ count: Int)
2222
}

Sources/AsyncHTTPClient/HTTPHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,13 @@ internal struct RedirectHandler<ResponseType> {
683683
extension RequestBodyLength {
684684
init(_ body: HTTPClient.Body?) {
685685
guard let body = body else {
686-
self = .fixed(0)
686+
self = .known(0)
687687
return
688688
}
689689
guard let length = body.length else {
690690
self = .unknown
691691
return
692692
}
693-
self = .fixed(length)
693+
self = .known(length)
694694
}
695695
}

Sources/AsyncHTTPClient/RequestValidation.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ extension HTTPHeaders {
2424

2525
if case .TRACE = method {
2626
switch bodyLength {
27-
case .fixed(0):
27+
case .known(0):
2828
break
29-
case .unknown, .fixed:
29+
case .unknown, .known:
3030
// A client MUST NOT send a message body in a TRACE request.
3131
// https://tools.ietf.org/html/rfc7230#section-4.3.8
3232
throw HTTPClientError.traceRequestWithBody
@@ -39,7 +39,7 @@ extension HTTPHeaders {
3939
switch bodyLength {
4040
case .unknown:
4141
return .init(connectionClose: connectionClose, body: .stream)
42-
case .fixed(let length):
42+
case .known(let length):
4343
return .init(connectionClose: connectionClose, body: .fixedSize(length))
4444
}
4545
}
@@ -88,7 +88,7 @@ extension HTTPHeaders {
8888
self.remove(name: "Transfer-Encoding")
8989

9090
switch bodyLength {
91-
case .fixed(0):
91+
case .known(0):
9292
// if we don't have a body we might not need to send the Content-Length field
9393
// https://tools.ietf.org/html/rfc7230#section-3.3.2
9494
switch method {
@@ -103,7 +103,7 @@ extension HTTPHeaders {
103103
// for an enclosed payload body.
104104
self.add(name: "Content-Length", value: "0")
105105
}
106-
case .fixed(let length):
106+
case .known(let length):
107107
self.add(name: "Content-Length", value: String(length))
108108
case .unknown:
109109
self.add(name: "Transfer-Encoding", value: "chunked")

Tests/AsyncHTTPClientTests/HTTPClientRequestTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class HTTPClientRequestTests: XCTestCase {
334334
request.method = .POST
335335

336336
let sequence = AnySequence(ByteBuffer(string: "post body").readableBytesView)
337-
request.body = .bytes(length: .fixed(9), sequence)
337+
request.body = .bytes(length: .known(9), sequence)
338338
var preparedRequest: PreparedRequest?
339339
XCTAssertNoThrow(preparedRequest = try PreparedRequest(request))
340340
guard let preparedRequest = preparedRequest else { return }
@@ -452,7 +452,7 @@ class HTTPClientRequestTests: XCTestCase {
452452
.asAsyncSequence()
453453
.map { ByteBuffer($0) }
454454

455-
request.body = .stream(length: .fixed(9), asyncSequence)
455+
request.body = .stream(length: .known(9), asyncSequence)
456456
var preparedRequest: PreparedRequest?
457457
XCTAssertNoThrow(preparedRequest = try PreparedRequest(request))
458458
guard let preparedRequest = preparedRequest else { return }
@@ -500,7 +500,7 @@ extension Optional where Wrapped == HTTPClientRequest.Body {
500500
return buffer
501501
case .sequence(let announcedLength, _, let generate):
502502
let buffer = generate(ByteBufferAllocator())
503-
if case .fixed(let announcedLength) = announcedLength,
503+
if case .known(let announcedLength) = announcedLength,
504504
announcedLength != buffer.readableBytes {
505505
throw LengthMismatch(announcedLength: announcedLength, actualLength: buffer.readableBytes)
506506
}
@@ -510,7 +510,7 @@ extension Optional where Wrapped == HTTPClientRequest.Body {
510510
while var buffer = try await generate(ByteBufferAllocator()) {
511511
accumulatedBuffer.writeBuffer(&buffer)
512512
}
513-
if case .fixed(let announcedLength) = announcedLength,
513+
if case .known(let announcedLength) = announcedLength,
514514
announcedLength != accumulatedBuffer.readableBytes {
515515
throw LengthMismatch(announcedLength: announcedLength, actualLength: accumulatedBuffer.readableBytes)
516516
}

0 commit comments

Comments
 (0)