Selaa lähdekoodia

Merge pull request #55 from mstarinteractive/fix-json-content-type

Fix content-types like "application/json; charset=utf-8"
Pierre-Olivier Latour 11 vuotta sitten
vanhempi
commit
6d550a02b7
1 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 2 1
      GCDWebServer/Requests/GCDWebServerDataRequest.m

+ 2 - 1
GCDWebServer/Requests/GCDWebServerDataRequest.m

@@ -97,7 +97,8 @@
 
 - (id)jsonObject {
   if (_jsonObject == nil) {
-    if ([self.contentType isEqualToString:@"application/json"] || [self.contentType isEqualToString:@"text/json"] || [self.contentType isEqualToString:@"text/javascript"]) {
+    NSString* mimeType = GCDWebServerTruncateHeaderValue(self.contentType);
+    if ([mimeType isEqualToString:@"application/json"] || [mimeType isEqualToString:@"text/json"] || [mimeType isEqualToString:@"text/javascript"]) {
       _jsonObject = ARC_RETAIN([NSJSONSerialization JSONObjectWithData:_data options:0 error:NULL]);
     } else {
       DNOT_REACHED();