Skip to content

Commit f1fcbb5

Browse files
committed
fix: request cannot have request body error
1 parent aaf0804 commit f1fcbb5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

templates/swift/Sources/Enums/Enum.swift.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import Foundation
33
public enum {{ enum.name | caseUcfirst | overrideIdentifier }}: String, CustomStringConvertible {
44
{%~ for value in enum.enum %}
55
{%~ set key = enum.keys is empty ? value : enum.keys[loop.index0] %}
6+
{% if key[0] matches '/\\d/' %}
7+
case _{{ key | caseEnumKey | escapeSwiftKeyword }} = "{{ value }}"
8+
{% else %}
69
case {{ key | caseEnumKey | escapeSwiftKeyword }} = "{{ value }}"
10+
{% endif %}
711
{%~ endfor %}
812

913
public var description: String {

templates/swift/Sources/WebSockets/HTTPHandler.swift.twig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ extension HTTPHandler : ChannelInboundHandler, RemovableChannelHandler {
4848
var headers = HTTPHeaders()
4949

5050
headers.add(name: "Host", value: "\(client.host):\(client.port)")
51-
headers.add(name: "Content-Type", value: "text/plain")
52-
headers.add(name: "Content-Length", value: "\(1)")
5351
headers.add(contentsOf: self.headers)
5452
headers.addDomainCookies(for: client.host)
5553
let requestHead = HTTPRequestHead(
@@ -60,7 +58,6 @@ extension HTTPHandler : ChannelInboundHandler, RemovableChannelHandler {
6058
)
6159

6260
context.write(wrapOutboundOut(.head(requestHead)), promise: nil)
63-
context.write(wrapOutboundOut(.body(.byteBuffer(ByteBuffer(string: "\r\n")))), promise: nil)
6461
context.writeAndFlush(wrapOutboundOut(.end(nil)), promise: nil)
6562
}
6663

0 commit comments

Comments
 (0)