Skip to content

Commit 2ab8a1c

Browse files
committed
Also detect XML in string sends
Well ... We should have a more elaborate magic number picker :-)
1 parent 27d7b91 commit 2ab8a1c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/express/ServerResponse.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ public extension ServerResponse {
153153
@inlinable
154154
func send(_ string: String) {
155155
if canAssignContentType {
156-
var ctype = string.hasPrefix("<html") ? "text/html" : "text/plain"
156+
var ctype = string.hasPrefix("<html")
157+
? "text/html"
158+
: string.hasPrefix("<?xml") ? "text/xml" : "text/plain"
157159
ctype += "; charset=utf-8"
158160
setHeader("Content-Type", ctype)
159161
}
160-
161-
write(string)
162-
end()
162+
send(Buffer(string))
163163
}
164164

165165
@inlinable

0 commit comments

Comments
 (0)