Jelajahi Sumber

wifi sharing: return correct content types for html, xml and css (closes #14083)

Felix Paul Kühne 10 tahun lalu
induk
melakukan
9ef7a97140
1 mengubah file dengan 21 tambahan dan 9 penghapusan
  1. 21 9
      Sources/VLCHTTPConnection.m

+ 21 - 9
Sources/VLCHTTPConnection.m

@@ -325,29 +325,41 @@
 
         NSString *deviceModel = [[UIDevice currentDevice] model];
         NSDictionary *replacementDict;
+        HTTPDynamicFileResponse *fileResponse;
 
         if ([relativePath isEqualToString:@"/libMediaVLC.xml"]) {
             replacementDict = @{@"FILES" : [mediaInXml componentsJoinedByString:@" "],
                                 @"NB_FILE" : [NSString stringWithFormat:@"%li", (unsigned long)mediaInXml.count],
                                 @"LIB_TITLE" : [[UIDevice currentDevice] name]};
-        } else
+
+            fileResponse = [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
+                                                               forConnection:self
+                                                                   separator:@"%%"
+                                                       replacementDictionary:replacementDict];
+            fileResponse.contentType = @"application/xml";
+        } else {
             replacementDict = @{@"FILES" : [mediaInHtml componentsJoinedByString:@" "],
                                 @"WEBINTF_TITLE" : NSLocalizedString(@"WEBINTF_TITLE", nil),
                                 @"WEBINTF_DROPFILES" : NSLocalizedString(@"WEBINTF_DROPFILES", nil),
                                 @"WEBINTF_DROPFILES_LONG" : [NSString stringWithFormat:NSLocalizedString(@"WEBINTF_DROPFILES_LONG", nil), deviceModel],
                                 @"WEBINTF_DOWNLOADFILES" : NSLocalizedString(@"WEBINTF_DOWNLOADFILES", nil),
                                 @"WEBINTF_DOWNLOADFILES_LONG" : [NSString stringWithFormat: NSLocalizedString(@"WEBINTF_DOWNLOADFILES_LONG", nil), deviceModel]};
+            fileResponse = [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
+                                                               forConnection:self
+                                                                   separator:@"%%"
+                                                       replacementDictionary:replacementDict];
+            fileResponse.contentType = @"text/html";
+        }
 
-        return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
-                                                   forConnection:self
-                                                       separator:@"%%"
-                                           replacementDictionary:replacementDict];
+        return fileResponse;
     } else if ([relativePath isEqualToString:@"/style.css"]) {
         NSDictionary *replacementDict = @{@"WEBINTF_TITLE" : NSLocalizedString(@"WEBINTF_TITLE", nil)};
-        return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
-                                                   forConnection:self
-                                                       separator:@"%%"
-                                           replacementDictionary:replacementDict];
+        HTTPDynamicFileResponse *fileResponse = [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
+                                                                                    forConnection:self
+                                                                                        separator:@"%%"
+                                                                            replacementDictionary:replacementDict];
+        fileResponse.contentType = @"text/css";
+        return fileResponse;
     }
 
     return [super httpResponseForMethod:method URI:path];