Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swisspol/GCDWebServer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.2.1
Choose a base ref
...
head repository: swisspol/GCDWebServer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing 860 changed files with 4,159 additions and 1,968 deletions.
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
BasedOnStyle: Google
Standard: Cpp11
ColumnLimit: 0
AlignTrailingComments: false
NamespaceIndentation: All
DerivePointerAlignment: false
AlwaysBreakBeforeMultilineStrings: false
AccessModifierOffset: -2
ObjCSpaceBeforeProtocolList: true
SortIncludes: false
---
Language: Cpp
---
Language: ObjC
...
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
xcuserdata
project.xcworkspace

Tests/Payload
/build
/Carthage/Build
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
language: objective-c
script: ./Run-Tests.sh
osx_image: xcode11.3
66 changes: 24 additions & 42 deletions iOS/AppDelegate.m → Frameworks/GCDWebServers.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2012-2014, Pierre-Olivier Latour
Copyright (c) 2012-2019, Pierre-Olivier Latour
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -25,46 +25,28 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "AppDelegate.h"
// GCDWebServer Core
#import "GCDWebServer.h"
#import "GCDWebServerConnection.h"
#import "GCDWebServerFunctions.h"
#import "GCDWebServerHTTPStatusCodes.h"
#import "GCDWebServerResponse.h"
#import "GCDWebServerRequest.h"

// GCDWebServer Requests
#import "GCDWebServerDataRequest.h"
#import "GCDWebServerFileRequest.h"
#import "GCDWebServerMultiPartFormRequest.h"
#import "GCDWebServerURLEncodedFormRequest.h"

// GCDWebServer Responses
#import "GCDWebServerDataResponse.h"
#import "GCDWebServerErrorResponse.h"
#import "GCDWebServerFileResponse.h"
#import "GCDWebServerStreamedResponse.h"

// GCDWebUploader
#import "GCDWebUploader.h"

@interface AppDelegate () <GCDWebUploaderDelegate> {
@private
GCDWebUploader* _webServer;
}
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
CGRect bounds = ([UIScreen instancesRespondToSelector:@selector(nativeBounds)] ? [[UIScreen mainScreen] nativeBounds] : [[UIScreen mainScreen] bounds]);
_window = [[UIWindow alloc] initWithFrame:bounds];
_window.backgroundColor = [UIColor whiteColor];
[_window makeKeyAndVisible];

NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
_webServer = [[GCDWebUploader alloc] initWithUploadDirectory:documentsPath];
_webServer.delegate = self;
_webServer.allowHiddenItems = YES;
[_webServer start];

return YES;
}

- (void)webUploader:(GCDWebUploader*)uploader didUploadFileAtPath:(NSString*)path {
NSLog(@"[UPLOAD] %@", path);
}

- (void)webUploader:(GCDWebUploader*)uploader didMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath {
NSLog(@"[MOVE] %@ -> %@", fromPath, toPath);
}

- (void)webUploader:(GCDWebUploader*)uploader didDeleteItemAtPath:(NSString*)path {
NSLog(@"[DELETE] %@", path);
}

- (void)webUploader:(GCDWebUploader*)uploader didCreateDirectoryAtPath:(NSString*)path {
NSLog(@"[CREATE] %@", path);
}

@end
// GCDWebDAVServer
#import "GCDWebDAVServer.h"
22 changes: 22 additions & 0 deletions Frameworks/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleVersion</key>
<string>${BUNDLE_VERSION_STRING}</string>
<key>CFBundleShortVersionString</key>
<string>${BUNDLE_VERSION_STRING}</string>
</dict>
</plist>
43 changes: 43 additions & 0 deletions Frameworks/Tests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#import <GCDWebServers/GCDWebServers.h>
#import <XCTest/XCTest.h>

#pragma clang diagnostic ignored "-Weverything" // Prevent "messaging to unqualified id" warnings

@interface Tests : XCTestCase
@end

@implementation Tests

- (void)testWebServer {
GCDWebServer* server = [[GCDWebServer alloc] init];
XCTAssertNotNil(server);
}

- (void)testDAVServer {
GCDWebDAVServer* server = [[GCDWebDAVServer alloc] init];
XCTAssertNotNil(server);
}

- (void)testWebUploader {
GCDWebUploader* server = [[GCDWebUploader alloc] init];
XCTAssertNotNil(server);
}

- (void)testPaths {
XCTAssertEqualObjects(GCDWebServerNormalizePath(@""), @"");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"/foo/"), @"/foo");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"foo/bar"), @"foo/bar");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"foo//bar"), @"foo/bar");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"foo/bar//"), @"foo/bar");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"foo/./bar"), @"foo/bar");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"foo/bar/."), @"foo/bar");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"foo/../bar"), @"bar");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"/foo/../bar"), @"/bar");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"/foo/.."), @"/");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"/.."), @"/");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"."), @"");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@".."), @"");
XCTAssertEqualObjects(GCDWebServerNormalizePath(@"../.."), @"");
}

@end
3 changes: 3 additions & 0 deletions Frameworks/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework module GCDWebServers {
umbrella header "GCDWebServers.h"
}
10 changes: 7 additions & 3 deletions GCDWebDAVServer/GCDWebDAVServer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2012-2014, Pierre-Olivier Latour
Copyright (c) 2012-2019, Pierre-Olivier Latour
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -27,6 +27,8 @@

#import "GCDWebServer.h"

NS_ASSUME_NONNULL_BEGIN

@class GCDWebDAVServer;

/**
@@ -86,14 +88,14 @@
/**
* Sets the delegate for the server.
*/
@property(nonatomic, assign) id<GCDWebDAVServerDelegate> delegate;
@property(nonatomic, weak, nullable) id<GCDWebDAVServerDelegate> delegate;

/**
* Sets which files are allowed to be operated on depending on their extension.
*
* The default value is nil i.e. all file extensions are allowed.
*/
@property(nonatomic, copy) NSArray* allowedFileExtensions;
@property(nonatomic, copy) NSArray<NSString*>* allowedFileExtensions;

/**
* Sets if files and directories whose name start with a period are allowed to
@@ -154,3 +156,5 @@
- (BOOL)shouldCreateDirectoryAtPath:(NSString*)path;

@end

NS_ASSUME_NONNULL_END
Loading