Commit decc24b0 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Use our own CocoaHTTPServer fork with our patches merged

parent 70ca8333
......@@ -236,15 +236,7 @@ else
cd WhiteRaccoon && git pull --rebase && cd ..
fi
if ! [ -e CocoaHTTPServer ]; then
git clone git://github.com/robbiehanson/CocoaHTTPServer.git
cd CocoaHTTPServer
git am ../../patches/cocoahttpserver/*.patch
if [ $? -ne 0 ]; then
git am --abort
info "Applying the patches failed, aborting git-am"
exit 1
fi
cd ..
git clone git://github.com/fkuehne/CocoaHTTPServer.git
else
cd CocoaHTTPServer && git pull --rebase && cd ..
fi
......
From ed78f177bf9772643f44cea1a7a1b6ba4ed77d46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sat, 15 Jun 2013 21:59:12 +0200
Subject: [PATCH 1/4] MultipartFormDataParser: fix future compilation warning
---
Core/Mime/MultipartFormDataParser.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Core/Mime/MultipartFormDataParser.m b/Core/Mime/MultipartFormDataParser.m
index 4a19aee..0676ba4 100644
--- a/Core/Mime/MultipartFormDataParser.m
+++ b/Core/Mime/MultipartFormDataParser.m
@@ -417,7 +417,7 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_WARN;
}
-- (int) numberOfBytesToLeavePendingWithData:(NSData*) data length:(int) length encoding:(int) encoding {
+- (int) numberOfBytesToLeavePendingWithData:(NSData*) data length:(NSUInteger) length encoding:(int) encoding {
// If we have BASE64 or Quoted-Printable encoded data, we have to be sure
// we don't break the format.
int sizeToLeavePending = 0;
--
1.7.12.4 (Apple Git-37)
From 945cd4165cb841fa120324fa633dc4e1f3ee4634 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sat, 15 Jun 2013 22:03:24 +0200
Subject: [PATCH 2/4] Respond with correct Content-Type for html, js, css, png
and jpg
---
Core/HTTPConnection.m | 17 +++++++++++++++++
Core/HTTPResponse.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/Core/HTTPConnection.m b/Core/HTTPConnection.m
index d4ac82f..2742415 100644
--- a/Core/HTTPConnection.m
+++ b/Core/HTTPConnection.m
@@ -1214,6 +1214,23 @@ static NSMutableArray *recentNonces;
}
else
{
+ /* add the proper MIME type */
+ NSString *mimeType;
+ NSString *pathExtension = [[httpResponse filePath] pathExtension];
+ if ([pathExtension isEqualToString:@"html"] || [pathExtension isEqualToString:@"htm"])
+ mimeType = @"text/html";
+ else if ([pathExtension isEqualToString:@"js"])
+ mimeType = @"text/javascript";
+ else if ([pathExtension isEqualToString:@"css"])
+ mimeType = @"text/css";
+ else if ([pathExtension isEqualToString:@"png"])
+ mimeType = @"image/png";
+ else if ([pathExtension isEqualToString:@"jpg"] || [pathExtension isEqualToString:@"jpeg"])
+ mimeType = @"image/jpeg";
+ else
+ mimeType = @"text/plain";
+ [response setHeaderField:@"Content-Type" value:mimeType];
+
// Write the header response
NSData *responseData = [self preprocessResponse:response];
[asyncSocket writeData:responseData withTimeout:TIMEOUT_WRITE_HEAD tag:HTTP_PARTIAL_RESPONSE_HEADER];
diff --git a/Core/HTTPResponse.h b/Core/HTTPResponse.h
index f303cf3..8b4963d 100644
--- a/Core/HTTPResponse.h
+++ b/Core/HTTPResponse.h
@@ -83,6 +83,8 @@
**/
- (void)connectionDidClose;
+- (NSString *)filePath;
+
@end
--
1.7.12.4 (Apple Git-37)
From d7cd8b0cb90ef0f5af3807b2eb5a042521560874 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sun, 16 Jun 2013 23:35:17 +0200
Subject: [PATCH 3/4] fix crash when uploading multiple files
---
Core/HTTPConnection.m | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/Core/HTTPConnection.m b/Core/HTTPConnection.m
index 2742415..95e283a 100644
--- a/Core/HTTPConnection.m
+++ b/Core/HTTPConnection.m
@@ -1215,20 +1215,20 @@ static NSMutableArray *recentNonces;
else
{
/* add the proper MIME type */
- NSString *mimeType;
- NSString *pathExtension = [[httpResponse filePath] pathExtension];
- if ([pathExtension isEqualToString:@"html"] || [pathExtension isEqualToString:@"htm"])
- mimeType = @"text/html";
- else if ([pathExtension isEqualToString:@"js"])
- mimeType = @"text/javascript";
- else if ([pathExtension isEqualToString:@"css"])
- mimeType = @"text/css";
- else if ([pathExtension isEqualToString:@"png"])
- mimeType = @"image/png";
- else if ([pathExtension isEqualToString:@"jpg"] || [pathExtension isEqualToString:@"jpeg"])
- mimeType = @"image/jpeg";
- else
- mimeType = @"text/plain";
+ NSString *mimeType = @"text/plain";
+ if ([httpResponse respondsToSelector:@selector(filePath)]) {
+ NSString *pathExtension = [[httpResponse filePath] pathExtension];
+ if ([pathExtension isEqualToString:@"html"] || [pathExtension isEqualToString:@"htm"])
+ mimeType = @"text/html";
+ else if ([pathExtension isEqualToString:@"js"])
+ mimeType = @"text/javascript";
+ else if ([pathExtension isEqualToString:@"css"])
+ mimeType = @"text/css";
+ else if ([pathExtension isEqualToString:@"png"])
+ mimeType = @"image/png";
+ else if ([pathExtension isEqualToString:@"jpg"] || [pathExtension isEqualToString:@"jpeg"])
+ mimeType = @"image/jpeg";
+ }
[response setHeaderField:@"Content-Type" value:mimeType];
// Write the header response
--
1.7.12.4 (Apple Git-37)
From 2e71373c6d8f390376c679dfe4676c5068612b60 Mon Sep 17 00:00:00 2001
From: Gleb Pinigin <gpinigin@gmail.com>
Date: Thu, 1 Aug 2013 19:22:27 +0700
Subject: [PATCH 4/4] bonjour: nullify delegate before removing service from
current runloop
---
Core/HTTPServer.m | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Core/HTTPServer.m b/Core/HTTPServer.m
index 57384f7..5983121 100644
--- a/Core/HTTPServer.m
+++ b/Core/HTTPServer.m
@@ -568,7 +568,7 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
if (type)
{
netService = [[NSNetService alloc] initWithDomain:domain type:type name:name port:[asyncSocket localPort]];
- [netService setDelegate:self];
+ netService.delegate = self;
NSNetService *theNetService = netService;
NSData *txtRecordData = nil;
@@ -576,8 +576,6 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
txtRecordData = [NSNetService dataFromTXTRecordDictionary:txtRecordDictionary];
dispatch_block_t bonjourBlock = ^{
-
- [theNetService removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
[theNetService scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
[theNetService publish];
@@ -603,10 +601,11 @@ static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
if (netService)
{
NSNetService *theNetService = netService;
+ netService.delegate = nil;
dispatch_block_t bonjourBlock = ^{
-
[theNetService stop];
+ [theNetService removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
};
[[self class] performBonjourBlock:bonjourBlock];
--
1.7.12.4 (Apple Git-37)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment