Explorar el Código

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

Fix content-types like "application/json; charset=utf-8"
Pierre-Olivier Latour hace 11 años
padre
commit
6d550a02b7
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      GCDWebServer/Requests/GCDWebServerDataRequest.m

+ 2 - 1
GCDWebServer/Requests/GCDWebServerDataRequest.m

@@ -97,7 +97,8 @@
 
 
 - (id)jsonObject {
 - (id)jsonObject {
   if (_jsonObject == nil) {
   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]);
       _jsonObject = ARC_RETAIN([NSJSONSerialization JSONObjectWithData:_data options:0 error:NULL]);
     } else {
     } else {
       DNOT_REACHED();
       DNOT_REACHED();