Quellcode durchsuchen

Merge pull request #474 from mtgto/set_content_type_to_response

Add Content-Type to HttpBody and Text HttpResponse
Victor Sigler vor 5 Jahren
Ursprung
Commit
718f82c26a
2 geänderte Dateien mit 6 neuen und 1 gelöschten Zeilen
  1. 4 0
      CHANGELOG.md
  2. 2 1
      Xcode/Sources/HttpResponse.swift

+ 4 - 0
CHANGELOG.md

@@ -18,6 +18,10 @@ All notable changes to this project will be documented in this file. Changes not
 
 # [Unreleased]
 
+## Added
+
+- Set `Content-Type` to HttpBody and Text HttpResponse. ([#474](https://github.com/httpswift/swifter/pull/474)) by [@mtgto](https://github.com/mtgto)
+
 ## Fixed
 
 * Fix misspell `serialise`. ([#473](https://github.com/httpswift/swifter/pull/473)) by [@mtgto](https://github.com/mtgto)

+ 2 - 1
Xcode/Sources/HttpResponse.swift

@@ -136,7 +136,8 @@ public enum HttpResponse {
         case .ok(let body):
             switch body {
             case .json: headers["Content-Type"] = "application/json"
-            case .html: headers["Content-Type"] = "text/html"
+            case .html, .htmlBody: headers["Content-Type"] = "text/html"
+            case .text: headers["Content-Type"] = "text/plain"
             case .data(_, let contentType): headers["Content-Type"] = contentType
             default:break
             }