├── .gitignore ├── .gitmodules ├── ARWebServerActivity.podspec ├── ARWebServerActivity ├── ARWebServerActivity.bundle │ ├── ARWebServerActivity-iOS6.png │ ├── ARWebServerActivity-iOS6@2x.png │ ├── ARWebServerActivity-iOS6@2x~ipad.png │ ├── ARWebServerActivity-iOS6~ipad.png │ ├── ARWebServerActivity@2x.png │ ├── ARWebServerActivity@2x~ipad.png │ ├── ARWebServerActivity~ipad.png │ ├── en.lproj │ │ └── ARWebServerActivity.strings │ └── es.lproj │ │ └── ARWebServerActivity.strings ├── ARWebServerActivity.h ├── ARWebServerActivity.m ├── ARWebServerActivityViewController.h └── ARWebServerActivityViewController.m ├── ARWebServerActivityExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcshareddata │ └── xcschemes │ │ └── ARWebServerActivityExample.xcscheme └── xcuserdata │ └── alexruperez.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── ARWebServerActivityExample ├── ARAppDelegate.h ├── ARAppDelegate.m ├── ARViewController.h ├── ARViewController.m ├── ARWebServerActivityExample-Info.plist ├── ARWebServerActivityExample-Prefix.pch ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── en.lproj │ └── InfoPlist.strings └── main.m ├── LICENSE ├── Podfile ├── Podfile.lock ├── Pods ├── GCDWebServer │ ├── GCDWebServer │ │ ├── Core │ │ │ ├── GCDWebServer.h │ │ │ ├── GCDWebServer.m │ │ │ ├── GCDWebServerConnection.h │ │ │ ├── GCDWebServerConnection.m │ │ │ ├── GCDWebServerFunctions.h │ │ │ ├── GCDWebServerFunctions.m │ │ │ ├── GCDWebServerHTTPStatusCodes.h │ │ │ ├── GCDWebServerPrivate.h │ │ │ ├── GCDWebServerRequest.h │ │ │ ├── GCDWebServerRequest.m │ │ │ ├── GCDWebServerResponse.h │ │ │ └── GCDWebServerResponse.m │ │ ├── Requests │ │ │ ├── GCDWebServerDataRequest.h │ │ │ ├── GCDWebServerDataRequest.m │ │ │ ├── GCDWebServerFileRequest.h │ │ │ ├── GCDWebServerFileRequest.m │ │ │ ├── GCDWebServerMultiPartFormRequest.h │ │ │ ├── GCDWebServerMultiPartFormRequest.m │ │ │ ├── GCDWebServerURLEncodedFormRequest.h │ │ │ └── GCDWebServerURLEncodedFormRequest.m │ │ └── Responses │ │ │ ├── GCDWebServerDataResponse.h │ │ │ ├── GCDWebServerDataResponse.m │ │ │ ├── GCDWebServerErrorResponse.h │ │ │ ├── GCDWebServerErrorResponse.m │ │ │ ├── GCDWebServerFileResponse.h │ │ │ ├── GCDWebServerFileResponse.m │ │ │ ├── GCDWebServerStreamedResponse.h │ │ │ └── GCDWebServerStreamedResponse.m │ ├── GCDWebUploader │ │ ├── GCDWebUploader.bundle │ │ │ ├── Info.plist │ │ │ ├── css │ │ │ │ ├── bootstrap-theme.css │ │ │ │ ├── bootstrap.css │ │ │ │ ├── index.css │ │ │ │ └── jquery.fileupload.css │ │ │ ├── en.lproj │ │ │ │ └── Localizable.strings │ │ │ ├── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ └── glyphicons-halflings-regular.woff │ │ │ ├── index.html │ │ │ └── js │ │ │ │ ├── bootstrap.min.js │ │ │ │ ├── html5shiv.min.js │ │ │ │ ├── index.js │ │ │ │ ├── jquery.fileupload.js │ │ │ │ ├── jquery.iframe-transport.js │ │ │ │ ├── jquery.jeditable.js │ │ │ │ ├── jquery.min.js │ │ │ │ ├── jquery.ui.widget.js │ │ │ │ ├── respond.min.js │ │ │ │ └── tmpl.min.js │ │ ├── GCDWebUploader.h │ │ └── GCDWebUploader.m │ ├── LICENSE │ └── README.md ├── Headers │ ├── Private │ │ ├── ARWebServerActivity │ │ │ ├── ARWebServerActivity.h │ │ │ └── ARWebServerActivityViewController.h │ │ └── GCDWebServer │ │ │ ├── GCDWebServer.h │ │ │ ├── GCDWebServerConnection.h │ │ │ ├── GCDWebServerDataRequest.h │ │ │ ├── GCDWebServerDataResponse.h │ │ │ ├── GCDWebServerErrorResponse.h │ │ │ ├── GCDWebServerFileRequest.h │ │ │ ├── GCDWebServerFileResponse.h │ │ │ ├── GCDWebServerFunctions.h │ │ │ ├── GCDWebServerHTTPStatusCodes.h │ │ │ ├── GCDWebServerMultiPartFormRequest.h │ │ │ ├── GCDWebServerPrivate.h │ │ │ ├── GCDWebServerRequest.h │ │ │ ├── GCDWebServerResponse.h │ │ │ ├── GCDWebServerStreamedResponse.h │ │ │ ├── GCDWebServerURLEncodedFormRequest.h │ │ │ └── GCDWebUploader.h │ └── Public │ │ ├── ARWebServerActivity │ │ ├── ARWebServerActivity.h │ │ └── ARWebServerActivityViewController.h │ │ └── GCDWebServer │ │ ├── GCDWebServer.h │ │ ├── GCDWebServerConnection.h │ │ ├── GCDWebServerDataRequest.h │ │ ├── GCDWebServerDataResponse.h │ │ ├── GCDWebServerErrorResponse.h │ │ ├── GCDWebServerFileRequest.h │ │ ├── GCDWebServerFileResponse.h │ │ ├── GCDWebServerFunctions.h │ │ ├── GCDWebServerHTTPStatusCodes.h │ │ ├── GCDWebServerMultiPartFormRequest.h │ │ ├── GCDWebServerRequest.h │ │ ├── GCDWebServerResponse.h │ │ ├── GCDWebServerStreamedResponse.h │ │ ├── GCDWebServerURLEncodedFormRequest.h │ │ └── GCDWebUploader.h ├── Local Podspecs │ └── ARWebServerActivity.podspec.json ├── Manifest.lock ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── ARWebServerActivity.xcscheme └── Target Support Files │ ├── ARWebServerActivity │ ├── ARWebServerActivity-dummy.m │ ├── ARWebServerActivity-prefix.pch │ └── ARWebServerActivity.xcconfig │ ├── GCDWebServer │ ├── GCDWebServer-dummy.m │ ├── GCDWebServer-prefix.pch │ └── GCDWebServer.xcconfig │ └── Pods │ ├── Pods-acknowledgements.markdown │ ├── Pods-acknowledgements.plist │ ├── Pods-dummy.m │ ├── Pods-frameworks.sh │ ├── Pods-resources.sh │ ├── Pods.debug.xcconfig │ └── Pods.release.xcconfig ├── README.md └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | #build file 4 | build/ 5 | #personal settings 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | #xcode state 13 | *.perspectivev3 14 | !default.perspectivev3 15 | *.xcworkspace 16 | !default.xcworkspace 17 | xcuserdata 18 | profile 19 | *.moved-aside 20 | DerivedData 21 | .idea/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Submodules/GCDWebServer"] 2 | path = Submodules/GCDWebServer 3 | url = git@github.com:swisspol/GCDWebServer.git 4 | -------------------------------------------------------------------------------- /ARWebServerActivity.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'ARWebServerActivity' 3 | s.version = '1.0.2' 4 | s.license = 'MIT' 5 | s.summary = 'A UIActivity subclass that share files via GCDWebServer with Twitter Bootstrap UI.' 6 | s.homepage = 'https://github.com/alexruperez/ARWebServerActivity' 7 | s.screenshots = "https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/master/screenshot.png" 8 | s.author = { "Alex Rupérez" => "contact@alexruperez.com" } 9 | s.social_media_url = "http://twitter.com/alexruperez" 10 | s.platform = :ios, '6.0' 11 | s.source = { :git => 'https://github.com/alexruperez/ARWebServerActivity.git', :tag => s.version.to_s } 12 | s.source_files = 'ARWebServerActivity/*.{h,m,swift}' 13 | s.resources = 'ARWebServerActivity/ARWebServerActivity.bundle' 14 | s.requires_arc = true 15 | s.frameworks = "UIKit", "CoreGraphics" 16 | s.dependency 'GCDWebServer/WebUploader', '~> 3.3' 17 | end 18 | -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6.png -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6@2x.png -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6@2x~ipad.png -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity-iOS6~ipad.png -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity@2x.png -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity@2x~ipad.png -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/ARWebServerActivity/ARWebServerActivity.bundle/ARWebServerActivity~ipad.png -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/en.lproj/ARWebServerActivity.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Created by alexruperez on 19/04/14. 3 | */ 4 | "Share via web server" = "Share via web server"; -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.bundle/es.lproj/ARWebServerActivity.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Created by alexruperez on 19/04/14. 3 | */ 4 | "Share via web server" = "Compartir por servidor web"; -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARWebServerActivity.h 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | 13 | @interface ARWebServerActivity : UIActivity 14 | 15 | @property (strong, nonatomic) NSNumber *port; 16 | @property (strong, nonatomic) NSString *bonjourName; 17 | @property (strong, nonatomic) NSString *path; 18 | @property (strong, nonatomic) UIViewController *activityViewController; 19 | 20 | - (instancetype)initWithPort:(NSNumber *)port bonjourName:(NSString *)bonjourName path:(NSString *)path activityViewController:(UIViewController *)activityViewController; 21 | 22 | - (BOOL)isRunning; 23 | - (BOOL)start; 24 | - (void)stop; 25 | - (NSURL *)serverURL; 26 | - (NSURL *)bonjourServerURL; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivity.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARWebServerActivity.m 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import "ARWebServerActivity.h" 10 | 11 | #import "GCDWebServerPrivate.h" 12 | #import "ARWebServerActivityViewController.h" 13 | 14 | @interface ARWebServerActivity () 15 | 16 | @property (strong, nonatomic) NSFileManager *fileManager; 17 | @property (strong, nonatomic) GCDWebUploader *webUploader; 18 | 19 | @end 20 | 21 | @implementation ARWebServerActivity 22 | 23 | - (instancetype)init 24 | { 25 | return [self initWithPort:nil bonjourName:nil path:nil activityViewController:nil]; 26 | } 27 | 28 | - (instancetype)initWithPort:(NSNumber *)port bonjourName:(NSString *)bonjourName path:(NSString *)path activityViewController:(UIViewController *)activityViewController 29 | { 30 | self = [super init]; 31 | if (self) 32 | { 33 | self.fileManager = [NSFileManager defaultManager]; 34 | 35 | self.port = port ? port : @80; 36 | 37 | self.bonjourName = bonjourName ? bonjourName : nil; 38 | 39 | self.path = path ? path : [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:[self activityType]]; 40 | 41 | [self setActivityViewController:activityViewController ? activityViewController : [[ARWebServerActivityViewController alloc] init]]; 42 | } 43 | return self; 44 | } 45 | 46 | - (GCDWebUploader *)webUploader 47 | { 48 | if (!_webUploader) 49 | { 50 | _webUploader = [[GCDWebUploader alloc] initWithUploadDirectory:self.path]; 51 | [_webUploader setDelegate:self]; 52 | } 53 | return _webUploader; 54 | } 55 | 56 | - (BOOL)isRunning 57 | { 58 | return [self.webUploader isRunning]; 59 | } 60 | 61 | - (BOOL)start 62 | { 63 | if ([self isRunning]) 64 | { 65 | return YES; 66 | } 67 | 68 | NSMutableDictionary *options = [[NSMutableDictionary alloc] init]; 69 | 70 | [options setObject:@NO forKey:GCDWebServerOption_AutomaticallySuspendInBackground]; 71 | if (self.port) 72 | { 73 | [options setObject:self.port forKey:GCDWebServerOption_Port]; 74 | } 75 | if (self.bonjourName) 76 | { 77 | [options setObject:self.bonjourName forKey:GCDWebServerOption_BonjourName]; 78 | } 79 | 80 | return [self.webUploader startWithOptions:options error:nil]; 81 | } 82 | 83 | - (void)stop 84 | { 85 | if ([self isRunning]) 86 | { 87 | [self.webUploader stop]; 88 | } 89 | } 90 | 91 | - (NSURL *)serverURL 92 | { 93 | return [self.webUploader serverURL]; 94 | } 95 | 96 | - (NSURL *)bonjourServerURL 97 | { 98 | return [self.webUploader bonjourServerURL]; 99 | } 100 | 101 | - (NSString *)activityType 102 | { 103 | return NSStringFromClass([self class]); 104 | } 105 | 106 | - (UIImage *)activityImage 107 | { 108 | NSString *activityType = [self activityType]; 109 | NSString *filename = [NSString stringWithFormat:@"%@.bundle/%@", activityType, activityType]; 110 | 111 | if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] == NSOrderedAscending) 112 | { 113 | filename = [filename stringByAppendingString:@"-iOS6"]; 114 | } 115 | 116 | return [UIImage imageNamed:filename inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil]; 117 | } 118 | 119 | - (NSString *)activityTitle 120 | { 121 | return NSLocalizedStringFromTableInBundle(@"Share via web server", [self activityType], [self bundle], nil); 122 | } 123 | 124 | - (BOOL)canPerformWithActivityItems:(NSArray *)activityItems 125 | { 126 | for (id activityItem in activityItems) 127 | { 128 | if ([activityItem isKindOfClass:[NSString class]] || [activityItem isKindOfClass:[UIImage class]] || [activityItem isKindOfClass:[NSURL class]] || [activityItem isKindOfClass:[NSData class]] || [activityItem isKindOfClass:[NSDictionary class]] || [activityItem isKindOfClass:[NSArray class]]) 129 | { 130 | return YES; 131 | } 132 | } 133 | return NO; 134 | } 135 | 136 | - (void)prepareWithActivityItems:(NSArray *)activityItems 137 | { 138 | NSError *error; 139 | if ([self.fileManager fileExistsAtPath:self.path]) 140 | { 141 | [self.fileManager removeItemAtPath:self.path error:&error]; 142 | } 143 | 144 | [self.fileManager createDirectoryAtPath:self.path withIntermediateDirectories:YES attributes:nil error:&error]; 145 | 146 | for (id activityItem in activityItems) 147 | { 148 | NSData *data; 149 | NSString *filename; 150 | if ([activityItem isKindOfClass:[NSString class]]) 151 | { 152 | data = [activityItem dataUsingEncoding:NSUTF8StringEncoding]; 153 | filename = [NSString stringWithFormat:@"%lu.txt", (unsigned long)[activityItems indexOfObject:activityItem]]; 154 | } 155 | if ([activityItem isKindOfClass:[UIImage class]]) 156 | { 157 | data = UIImagePNGRepresentation(activityItem); 158 | filename = [NSString stringWithFormat:@"%lu.png", (unsigned long)[activityItems indexOfObject:activityItem]]; 159 | } 160 | if ([activityItem isKindOfClass:[NSURL class]]) 161 | { 162 | if ([activityItem isFileURL]) 163 | { 164 | if ([self.fileManager fileExistsAtPath:[(NSURL *)activityItem path]]) 165 | { 166 | data = [NSData dataWithContentsOfFile:[(NSURL *)activityItem path]]; 167 | filename = [[(NSURL *)activityItem path] lastPathComponent]; 168 | } 169 | } 170 | else 171 | { 172 | data = [NSData dataWithContentsOfURL:activityItem]; 173 | filename = [[(NSURL *)activityItem path] lastPathComponent]; 174 | } 175 | } 176 | if ([activityItem isKindOfClass:[NSData class]]) 177 | { 178 | data = activityItem; 179 | filename = [NSString stringWithFormat:@"%lu.data", (unsigned long)[activityItems indexOfObject:activityItem]]; 180 | } 181 | if ([activityItem isKindOfClass:[NSDictionary class]] || [activityItem isKindOfClass:[NSArray class]]) 182 | { 183 | data = [NSJSONSerialization dataWithJSONObject:activityItem options:NSJSONWritingPrettyPrinted error:&error]; 184 | filename = [NSString stringWithFormat:@"%lu.json", (unsigned long)[activityItems indexOfObject:activityItem]]; 185 | } 186 | if (data && filename) 187 | { 188 | [self.fileManager createFileAtPath:[self.path stringByAppendingPathComponent:filename] contents:data attributes:nil]; 189 | } 190 | } 191 | } 192 | 193 | - (UIViewController *)activityViewController 194 | { 195 | if ([_activityViewController respondsToSelector:@selector(setWebServerActivity:)]) 196 | { 197 | [(ARWebServerActivityViewController *)_activityViewController setWebServerActivity:self]; 198 | } 199 | 200 | [self start]; 201 | 202 | return _activityViewController; 203 | } 204 | 205 | - (void)activityDidFinish:(BOOL)completed 206 | { 207 | [self stop]; 208 | 209 | NSError *error; 210 | if ([self.fileManager fileExistsAtPath:self.path]) 211 | { 212 | [self.fileManager removeItemAtPath:self.path error:&error]; 213 | } 214 | 215 | [super activityDidFinish:completed]; 216 | } 217 | 218 | - (NSBundle *)bundle 219 | { 220 | NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:[self activityType] withExtension:@"bundle"]; 221 | if (bundleURL) 222 | { 223 | return [NSBundle bundleWithURL:bundleURL]; 224 | } 225 | 226 | return [NSBundle mainBundle]; 227 | } 228 | 229 | @end 230 | -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivityViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARWebServerActivityViewController.h 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ARWebServerActivity.h" 11 | 12 | @interface ARWebServerActivityViewController : UIViewController 13 | 14 | @property (strong, nonatomic) ARWebServerActivity *webServerActivity; 15 | 16 | - (IBAction)goToSafari:(id)sender; 17 | - (IBAction)activityDidFinish:(id)sender; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ARWebServerActivity/ARWebServerActivityViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARWebServerActivityViewController.m 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import "ARWebServerActivityViewController.h" 10 | 11 | @interface ARWebServerActivityViewController () 12 | 13 | @end 14 | 15 | @implementation ARWebServerActivityViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | 21 | if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) 22 | { 23 | [self setNeedsStatusBarAppearanceUpdate]; 24 | } 25 | 26 | [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(activityDidFinish:)]]; 27 | } 28 | 29 | - (void)viewWillAppear:(BOOL)animated 30 | { 31 | [super viewWillAppear:animated]; 32 | 33 | [self addDefaultSubviewsToView:self.view]; 34 | } 35 | 36 | - (void)viewDidAppear:(BOOL)animated 37 | { 38 | [super viewDidAppear:animated]; 39 | 40 | [UIView animateWithDuration:0.3f animations:^{ 41 | [self.view setBackgroundColor:[UIColor colorWithWhite:0.0f alpha:0.3f]]; 42 | }]; 43 | } 44 | 45 | - (UIStatusBarStyle)preferredStatusBarStyle 46 | { 47 | return UIStatusBarStyleLightContent; 48 | } 49 | 50 | - (IBAction)goToSafari:(id)sender 51 | { 52 | if (self.webServerActivity && [self.webServerActivity isRunning] && [self.webServerActivity port]) 53 | { 54 | if (![[self.webServerActivity port] isEqualToNumber:@80]) 55 | { 56 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:%@/", [self.webServerActivity port]]]]; 57 | } 58 | else 59 | { 60 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://localhost/"]]; 61 | } 62 | } 63 | } 64 | 65 | - (IBAction)activityDidFinish:(id)sender 66 | { 67 | if (self.webServerActivity) 68 | { 69 | [self.view setBackgroundColor:[UIColor clearColor]]; 70 | [self.webServerActivity activityDidFinish:YES]; 71 | } 72 | } 73 | 74 | - (void)addDefaultSubviewsToView:(UIView *)view 75 | { 76 | UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, [[UIScreen mainScreen] bounds].size.height - 100.0f, [[UIScreen mainScreen] bounds].size.width, 100.0f)]; 77 | [view addSubview:toolbar]; 78 | 79 | UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, [[UIScreen mainScreen] bounds].size.height - 100.0f, [[UIScreen mainScreen] bounds].size.width, 100.0f)]; 80 | [button addTarget:self action:@selector(goToSafari:) forControlEvents:UIControlEventTouchUpInside]; 81 | [button setTitleColor:[view tintColor] forState:UIControlStateNormal]; 82 | if (self.webServerActivity && [self.webServerActivity isRunning] && [self.webServerActivity serverURL] && [[UIApplication sharedApplication] canOpenURL:[self.webServerActivity serverURL]]) 83 | { 84 | [button setTitle:[[self.webServerActivity serverURL] absoluteString] forState:UIControlStateNormal]; 85 | } 86 | else if (self.webServerActivity && [self.webServerActivity isRunning] && [self.webServerActivity port]) 87 | { 88 | if (![[self.webServerActivity port] isEqualToNumber:@80]) 89 | { 90 | [button setTitle:[NSString stringWithFormat:@"http://localhost:%@/", [self.webServerActivity port]] forState:UIControlStateNormal]; 91 | } 92 | else 93 | { 94 | [button setTitle:@"http://localhost/" forState:UIControlStateNormal]; 95 | } 96 | } 97 | [view addSubview:button]; 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /ARWebServerActivityExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ARWebServerActivityExample.xcodeproj/xcshareddata/xcschemes/ARWebServerActivityExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /ARWebServerActivityExample.xcodeproj/xcuserdata/alexruperez.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ARWebServerActivityExample.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D53CE7A21901811D000B96C4 16 | 17 | primary 18 | 19 | 20 | D53CE7C61901811D000B96C4 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/ARAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARAppDelegate.h 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ARAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/ARAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARAppDelegate.m 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import "ARAppDelegate.h" 10 | #import "ARViewController.h" 11 | 12 | @implementation ARAppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | // Override point for customization after application launch. 17 | 18 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 19 | self.window.backgroundColor = [UIColor whiteColor]; 20 | [self.window setRootViewController:[[ARViewController alloc] init]]; 21 | [self.window makeKeyAndVisible]; 22 | 23 | return YES; 24 | } 25 | 26 | - (void)applicationWillResignActive:(UIApplication *)application 27 | { 28 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 29 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 30 | } 31 | 32 | - (void)applicationDidEnterBackground:(UIApplication *)application 33 | { 34 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 35 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 36 | } 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application 39 | { 40 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 41 | } 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application 44 | { 45 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 46 | } 47 | 48 | - (void)applicationWillTerminate:(UIApplication *)application 49 | { 50 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/ARViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARViewController.h 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ARViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/ARViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARViewController.m 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import "ARViewController.h" 10 | #import 11 | 12 | @interface ARViewController () 13 | 14 | @end 15 | 16 | @implementation ARViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | UIButton *showActivitiesButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 23 | [showActivitiesButton setTitle:NSLocalizedString(@"Show Activities", @"Show Activities button") forState:UIControlStateNormal]; 24 | [showActivitiesButton addTarget:self action:@selector(showActivities:) forControlEvents:UIControlEventTouchUpInside]; 25 | CGSize screenSize = [UIScreen mainScreen].bounds.size; 26 | [showActivitiesButton setFrame:CGRectMake((screenSize.width/2)-100, (screenSize.height/2)-30, 200, 60)]; 27 | [self.view addSubview:showActivitiesButton]; 28 | } 29 | 30 | - (void)showActivities:(UIButton *)button 31 | { 32 | ARWebServerActivity *webServerActivity = [[ARWebServerActivity alloc] init]; 33 | 34 | UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Hello World!", [UIImage imageNamed:[NSString stringWithFormat:@"%@.bundle/%@", webServerActivity.activityType, webServerActivity.activityType]], [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[NSString stringWithFormat:@"%@.bundle/%@", webServerActivity.activityType, webServerActivity.activityType] stringByAppendingString:@"@2x~ipad"] ofType:@"png"]], [NSURL URLWithString:@"http://humanstxt.org/humans.txt"], [@"data" dataUsingEncoding:NSUTF8StringEncoding], @{@"key": @[@"value1", @"value2"]}, @[@"value1", @"value2"]] applicationActivities:@[webServerActivity]]; 35 | 36 | if ([activityViewController respondsToSelector:NSSelectorFromString(@"popoverPresentationController")]) 37 | { 38 | activityViewController.popoverPresentationController.sourceView = button; 39 | activityViewController.popoverPresentationController.sourceRect = button.bounds; 40 | } 41 | 42 | [self presentViewController:activityViewController animated:YES completion:nil]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/ARWebServerActivityExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ARWebServer 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIRequiresPersistentWiFi 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | 38 | UISupportedInterfaceOrientations~ipad 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationPortraitUpsideDown 42 | 43 | NSAppTransportSecurity 44 | 45 | NSAllowsArbitraryLoads 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/ARWebServerActivityExample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "3x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "3x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "57x57", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "57x57", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "iphone", 45 | "size" : "60x60", 46 | "scale" : "3x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "29x29", 51 | "scale" : "1x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "2x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "40x40", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "2x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "50x50", 71 | "scale" : "1x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "50x50", 76 | "scale" : "2x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "72x72", 81 | "scale" : "1x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "72x72", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ipad", 90 | "size" : "76x76", 91 | "scale" : "1x" 92 | }, 93 | { 94 | "idiom" : "ipad", 95 | "size" : "76x76", 96 | "scale" : "2x" 97 | }, 98 | { 99 | "idiom" : "ipad", 100 | "size" : "83.5x83.5", 101 | "scale" : "2x" 102 | } 103 | ], 104 | "info" : { 105 | "version" : 1, 106 | "author" : "xcode" 107 | } 108 | } -------------------------------------------------------------------------------- /ARWebServerActivityExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ARWebServerActivityExample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "8.0", 8 | "subtype" : "736h", 9 | "scale" : "3x" 10 | }, 11 | { 12 | "orientation" : "landscape", 13 | "idiom" : "iphone", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "8.0", 16 | "subtype" : "736h", 17 | "scale" : "3x" 18 | }, 19 | { 20 | "orientation" : "portrait", 21 | "idiom" : "iphone", 22 | "extent" : "full-screen", 23 | "minimum-system-version" : "8.0", 24 | "subtype" : "667h", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "orientation" : "portrait", 29 | "idiom" : "iphone", 30 | "extent" : "full-screen", 31 | "minimum-system-version" : "7.0", 32 | "scale" : "2x" 33 | }, 34 | { 35 | "orientation" : "portrait", 36 | "idiom" : "iphone", 37 | "extent" : "full-screen", 38 | "minimum-system-version" : "7.0", 39 | "subtype" : "retina4", 40 | "scale" : "2x" 41 | }, 42 | { 43 | "orientation" : "portrait", 44 | "idiom" : "ipad", 45 | "extent" : "full-screen", 46 | "minimum-system-version" : "7.0", 47 | "scale" : "1x" 48 | }, 49 | { 50 | "orientation" : "landscape", 51 | "idiom" : "ipad", 52 | "extent" : "full-screen", 53 | "minimum-system-version" : "7.0", 54 | "scale" : "1x" 55 | }, 56 | { 57 | "orientation" : "portrait", 58 | "idiom" : "ipad", 59 | "extent" : "full-screen", 60 | "minimum-system-version" : "7.0", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "orientation" : "landscape", 65 | "idiom" : "ipad", 66 | "extent" : "full-screen", 67 | "minimum-system-version" : "7.0", 68 | "scale" : "2x" 69 | }, 70 | { 71 | "orientation" : "portrait", 72 | "idiom" : "iphone", 73 | "extent" : "full-screen", 74 | "scale" : "1x" 75 | }, 76 | { 77 | "orientation" : "portrait", 78 | "idiom" : "iphone", 79 | "extent" : "full-screen", 80 | "scale" : "2x" 81 | }, 82 | { 83 | "orientation" : "portrait", 84 | "idiom" : "iphone", 85 | "extent" : "full-screen", 86 | "subtype" : "retina4", 87 | "scale" : "2x" 88 | }, 89 | { 90 | "orientation" : "portrait", 91 | "idiom" : "ipad", 92 | "extent" : "to-status-bar", 93 | "scale" : "1x" 94 | }, 95 | { 96 | "orientation" : "portrait", 97 | "idiom" : "ipad", 98 | "extent" : "full-screen", 99 | "scale" : "1x" 100 | }, 101 | { 102 | "orientation" : "landscape", 103 | "idiom" : "ipad", 104 | "extent" : "to-status-bar", 105 | "scale" : "1x" 106 | }, 107 | { 108 | "orientation" : "landscape", 109 | "idiom" : "ipad", 110 | "extent" : "full-screen", 111 | "scale" : "1x" 112 | }, 113 | { 114 | "orientation" : "portrait", 115 | "idiom" : "ipad", 116 | "extent" : "to-status-bar", 117 | "scale" : "2x" 118 | }, 119 | { 120 | "orientation" : "portrait", 121 | "idiom" : "ipad", 122 | "extent" : "full-screen", 123 | "scale" : "2x" 124 | }, 125 | { 126 | "orientation" : "landscape", 127 | "idiom" : "ipad", 128 | "extent" : "to-status-bar", 129 | "scale" : "2x" 130 | }, 131 | { 132 | "orientation" : "landscape", 133 | "idiom" : "ipad", 134 | "extent" : "full-screen", 135 | "scale" : "2x" 136 | } 137 | ], 138 | "info" : { 139 | "version" : 1, 140 | "author" : "xcode" 141 | } 142 | } -------------------------------------------------------------------------------- /ARWebServerActivityExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /ARWebServerActivityExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ARWebServerActivityExample 4 | // 5 | // Created by alexruperez on 18/04/14. 6 | // Copyright (c) 2014 alexruperez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "ARAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([ARAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2013 alexruperez 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | pod "ARWebServerActivity", :path => "./" -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ARWebServerActivity (1.0.1): 3 | - GCDWebServer/WebUploader (~> 3.3) 4 | - GCDWebServer/Core (3.3.2) 5 | - GCDWebServer/WebUploader (3.3.2): 6 | - GCDWebServer/WebUploader/Core (= 3.3.2) 7 | - GCDWebServer/WebUploader/Core (3.3.2): 8 | - GCDWebServer/Core 9 | 10 | DEPENDENCIES: 11 | - ARWebServerActivity (from `./`) 12 | 13 | EXTERNAL SOURCES: 14 | ARWebServerActivity: 15 | :path: "./" 16 | 17 | SPEC CHECKSUMS: 18 | ARWebServerActivity: 11da4907792fbea0b67eec5339d4848852dbbf41 19 | GCDWebServer: 2a375ec42839a41d7187d04e5b688d32fa5c4cd5 20 | 21 | COCOAPODS: 0.39.0 22 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerConnection.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServer.h" 29 | 30 | @class GCDWebServerHandler; 31 | 32 | /** 33 | * The GCDWebServerConnection class is instantiated by GCDWebServer to handle 34 | * each new HTTP connection. Each instance stays alive until the connection is 35 | * closed. 36 | * 37 | * You cannot use this class directly, but it is made public so you can 38 | * subclass it to override some hooks. Use the GCDWebServerOption_ConnectionClass 39 | * option for GCDWebServer to install your custom subclass. 40 | * 41 | * @warning The GCDWebServerConnection retains the GCDWebServer until the 42 | * connection is closed. 43 | */ 44 | @interface GCDWebServerConnection : NSObject 45 | 46 | /** 47 | * Returns the GCDWebServer that owns the connection. 48 | */ 49 | @property(nonatomic, readonly) GCDWebServer* server; 50 | 51 | /** 52 | * Returns YES if the connection is using IPv6. 53 | */ 54 | @property(nonatomic, readonly, getter=isUsingIPv6) BOOL usingIPv6; 55 | 56 | /** 57 | * Returns the address of the local peer (i.e. server) of the connection 58 | * as a raw "struct sockaddr". 59 | */ 60 | @property(nonatomic, readonly) NSData* localAddressData; 61 | 62 | /** 63 | * Returns the address of the local peer (i.e. server) of the connection 64 | * as a string. 65 | */ 66 | @property(nonatomic, readonly) NSString* localAddressString; 67 | 68 | /** 69 | * Returns the address of the remote peer (i.e. client) of the connection 70 | * as a raw "struct sockaddr". 71 | */ 72 | @property(nonatomic, readonly) NSData* remoteAddressData; 73 | 74 | /** 75 | * Returns the address of the remote peer (i.e. client) of the connection 76 | * as a string. 77 | */ 78 | @property(nonatomic, readonly) NSString* remoteAddressString; 79 | 80 | /** 81 | * Returns the total number of bytes received from the remote peer (i.e. client) 82 | * so far. 83 | */ 84 | @property(nonatomic, readonly) NSUInteger totalBytesRead; 85 | 86 | /** 87 | * Returns the total number of bytes sent to the remote peer (i.e. client) so far. 88 | */ 89 | @property(nonatomic, readonly) NSUInteger totalBytesWritten; 90 | 91 | @end 92 | 93 | /** 94 | * Hooks to customize the behavior of GCDWebServer HTTP connections. 95 | * 96 | * @warning These methods can be called on any GCD thread. 97 | * Be sure to also call "super" when overriding them. 98 | */ 99 | @interface GCDWebServerConnection (Subclassing) 100 | 101 | /** 102 | * This method is called when the connection is opened. 103 | * 104 | * Return NO to reject the connection e.g. after validating the local 105 | * or remote address. 106 | */ 107 | - (BOOL)open; 108 | 109 | /** 110 | * This method is called whenever data has been received 111 | * from the remote peer (i.e. client). 112 | * 113 | * @warning Do not attempt to modify this data. 114 | */ 115 | - (void)didReadBytes:(const void*)bytes length:(NSUInteger)length; 116 | 117 | /** 118 | * This method is called whenever data has been sent 119 | * to the remote peer (i.e. client). 120 | * 121 | * @warning Do not attempt to modify this data. 122 | */ 123 | - (void)didWriteBytes:(const void*)bytes length:(NSUInteger)length; 124 | 125 | /** 126 | * This method is called after the HTTP headers have been received to 127 | * allow replacing the request URL by another one. 128 | * 129 | * The default implementation returns the original URL. 130 | */ 131 | - (NSURL*)rewriteRequestURL:(NSURL*)url withMethod:(NSString*)method headers:(NSDictionary*)headers; 132 | 133 | /** 134 | * Assuming a valid HTTP request was received, this method is called before 135 | * the request is processed. 136 | * 137 | * Return a non-nil GCDWebServerResponse to bypass the request processing entirely. 138 | * 139 | * The default implementation checks for HTTP authentication if applicable 140 | * and returns a barebone 401 status code response if authentication failed. 141 | */ 142 | - (GCDWebServerResponse*)preflightRequest:(GCDWebServerRequest*)request; 143 | 144 | /** 145 | * Assuming a valid HTTP request was received and -preflightRequest: returned nil, 146 | * this method is called to process the request by executing the handler's 147 | * process block. 148 | */ 149 | - (void)processRequest:(GCDWebServerRequest*)request completion:(GCDWebServerCompletionBlock)completion; 150 | 151 | /** 152 | * Assuming a valid HTTP request was received and either -preflightRequest: 153 | * or -processRequest:completion: returned a non-nil GCDWebServerResponse, 154 | * this method is called to override the response. 155 | * 156 | * You can either modify the current response and return it, or return a 157 | * completely new one. 158 | * 159 | * The default implementation replaces any response matching the "ETag" or 160 | * "Last-Modified-Date" header of the request by a barebone "Not-Modified" (304) 161 | * one. 162 | */ 163 | - (GCDWebServerResponse*)overrideResponse:(GCDWebServerResponse*)response forRequest:(GCDWebServerRequest*)request; 164 | 165 | /** 166 | * This method is called if any error happens while validing or processing 167 | * the request or if no GCDWebServerResponse was generated during processing. 168 | * 169 | * @warning If the request was invalid (e.g. the HTTP headers were malformed), 170 | * the "request" argument will be nil. 171 | */ 172 | - (void)abortRequest:(GCDWebServerRequest*)request withStatusCode:(NSInteger)statusCode; 173 | 174 | /** 175 | * Called when the connection is closed. 176 | */ 177 | - (void)close; 178 | 179 | @end 180 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * Converts a file extension to the corresponding MIME type. 36 | * If there is no match, "application/octet-stream" is returned. 37 | */ 38 | NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension); 39 | 40 | /** 41 | * Add percent-escapes to a string so it can be used in a URL. 42 | * The legal characters ":@/?&=+" are also escaped to ensure compatibility 43 | * with URL encoded forms and URL queries. 44 | */ 45 | NSString* GCDWebServerEscapeURLString(NSString* string); 46 | 47 | /** 48 | * Unescapes a URL percent-encoded string. 49 | */ 50 | NSString* GCDWebServerUnescapeURLString(NSString* string); 51 | 52 | /** 53 | * Extracts the unescaped names and values from an 54 | * "application/x-www-form-urlencoded" form. 55 | * http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1 56 | */ 57 | NSDictionary* GCDWebServerParseURLEncodedForm(NSString* form); 58 | 59 | /** 60 | * On OS X, returns the IPv4 or IPv6 address as a string of the primary 61 | * connected service or nil if not available. 62 | * 63 | * On iOS, returns the IPv4 or IPv6 address as a string of the WiFi 64 | * interface if connected or nil otherwise. 65 | */ 66 | NSString* GCDWebServerGetPrimaryIPAddress(BOOL useIPv6); 67 | 68 | /** 69 | * Converts a date into a string using RFC822 formatting. 70 | * https://tools.ietf.org/html/rfc822#section-5 71 | * https://tools.ietf.org/html/rfc1123#section-5.2.14 72 | */ 73 | NSString* GCDWebServerFormatRFC822(NSDate* date); 74 | 75 | /** 76 | * Converts a RFC822 formatted string into a date. 77 | * https://tools.ietf.org/html/rfc822#section-5 78 | * https://tools.ietf.org/html/rfc1123#section-5.2.14 79 | * 80 | * @warning Timezones other than GMT are not supported by this function. 81 | */ 82 | NSDate* GCDWebServerParseRFC822(NSString* string); 83 | 84 | /** 85 | * Converts a date into a string using IOS 8601 formatting. 86 | * http://tools.ietf.org/html/rfc3339#section-5.6 87 | */ 88 | NSString* GCDWebServerFormatISO8601(NSDate* date); 89 | 90 | /** 91 | * Converts a ISO 8601 formatted string into a date. 92 | * http://tools.ietf.org/html/rfc3339#section-5.6 93 | * 94 | * @warning Only "calendar" variant is supported at this time and timezones 95 | * other than GMT are not supported either. 96 | */ 97 | NSDate* GCDWebServerParseISO8601(NSString* string); 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 29 | // http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml 30 | 31 | #import 32 | 33 | /** 34 | * Convenience constants for "informational" HTTP status codes. 35 | */ 36 | typedef NS_ENUM(NSInteger, GCDWebServerInformationalHTTPStatusCode) { 37 | kGCDWebServerHTTPStatusCode_Continue = 100, 38 | kGCDWebServerHTTPStatusCode_SwitchingProtocols = 101, 39 | kGCDWebServerHTTPStatusCode_Processing = 102 40 | }; 41 | 42 | /** 43 | * Convenience constants for "successful" HTTP status codes. 44 | */ 45 | typedef NS_ENUM(NSInteger, GCDWebServerSuccessfulHTTPStatusCode) { 46 | kGCDWebServerHTTPStatusCode_OK = 200, 47 | kGCDWebServerHTTPStatusCode_Created = 201, 48 | kGCDWebServerHTTPStatusCode_Accepted = 202, 49 | kGCDWebServerHTTPStatusCode_NonAuthoritativeInformation = 203, 50 | kGCDWebServerHTTPStatusCode_NoContent = 204, 51 | kGCDWebServerHTTPStatusCode_ResetContent = 205, 52 | kGCDWebServerHTTPStatusCode_PartialContent = 206, 53 | kGCDWebServerHTTPStatusCode_MultiStatus = 207, 54 | kGCDWebServerHTTPStatusCode_AlreadyReported = 208 55 | }; 56 | 57 | /** 58 | * Convenience constants for "redirection" HTTP status codes. 59 | */ 60 | typedef NS_ENUM(NSInteger, GCDWebServerRedirectionHTTPStatusCode) { 61 | kGCDWebServerHTTPStatusCode_MultipleChoices = 300, 62 | kGCDWebServerHTTPStatusCode_MovedPermanently = 301, 63 | kGCDWebServerHTTPStatusCode_Found = 302, 64 | kGCDWebServerHTTPStatusCode_SeeOther = 303, 65 | kGCDWebServerHTTPStatusCode_NotModified = 304, 66 | kGCDWebServerHTTPStatusCode_UseProxy = 305, 67 | kGCDWebServerHTTPStatusCode_TemporaryRedirect = 307, 68 | kGCDWebServerHTTPStatusCode_PermanentRedirect = 308 69 | }; 70 | 71 | /** 72 | * Convenience constants for "client error" HTTP status codes. 73 | */ 74 | typedef NS_ENUM(NSInteger, GCDWebServerClientErrorHTTPStatusCode) { 75 | kGCDWebServerHTTPStatusCode_BadRequest = 400, 76 | kGCDWebServerHTTPStatusCode_Unauthorized = 401, 77 | kGCDWebServerHTTPStatusCode_PaymentRequired = 402, 78 | kGCDWebServerHTTPStatusCode_Forbidden = 403, 79 | kGCDWebServerHTTPStatusCode_NotFound = 404, 80 | kGCDWebServerHTTPStatusCode_MethodNotAllowed = 405, 81 | kGCDWebServerHTTPStatusCode_NotAcceptable = 406, 82 | kGCDWebServerHTTPStatusCode_ProxyAuthenticationRequired = 407, 83 | kGCDWebServerHTTPStatusCode_RequestTimeout = 408, 84 | kGCDWebServerHTTPStatusCode_Conflict = 409, 85 | kGCDWebServerHTTPStatusCode_Gone = 410, 86 | kGCDWebServerHTTPStatusCode_LengthRequired = 411, 87 | kGCDWebServerHTTPStatusCode_PreconditionFailed = 412, 88 | kGCDWebServerHTTPStatusCode_RequestEntityTooLarge = 413, 89 | kGCDWebServerHTTPStatusCode_RequestURITooLong = 414, 90 | kGCDWebServerHTTPStatusCode_UnsupportedMediaType = 415, 91 | kGCDWebServerHTTPStatusCode_RequestedRangeNotSatisfiable = 416, 92 | kGCDWebServerHTTPStatusCode_ExpectationFailed = 417, 93 | kGCDWebServerHTTPStatusCode_UnprocessableEntity = 422, 94 | kGCDWebServerHTTPStatusCode_Locked = 423, 95 | kGCDWebServerHTTPStatusCode_FailedDependency = 424, 96 | kGCDWebServerHTTPStatusCode_UpgradeRequired = 426, 97 | kGCDWebServerHTTPStatusCode_PreconditionRequired = 428, 98 | kGCDWebServerHTTPStatusCode_TooManyRequests = 429, 99 | kGCDWebServerHTTPStatusCode_RequestHeaderFieldsTooLarge = 431 100 | }; 101 | 102 | /** 103 | * Convenience constants for "server error" HTTP status codes. 104 | */ 105 | typedef NS_ENUM(NSInteger, GCDWebServerServerErrorHTTPStatusCode) { 106 | kGCDWebServerHTTPStatusCode_InternalServerError = 500, 107 | kGCDWebServerHTTPStatusCode_NotImplemented = 501, 108 | kGCDWebServerHTTPStatusCode_BadGateway = 502, 109 | kGCDWebServerHTTPStatusCode_ServiceUnavailable = 503, 110 | kGCDWebServerHTTPStatusCode_GatewayTimeout = 504, 111 | kGCDWebServerHTTPStatusCode_HTTPVersionNotSupported = 505, 112 | kGCDWebServerHTTPStatusCode_InsufficientStorage = 507, 113 | kGCDWebServerHTTPStatusCode_LoopDetected = 508, 114 | kGCDWebServerHTTPStatusCode_NotExtended = 510, 115 | kGCDWebServerHTTPStatusCode_NetworkAuthenticationRequired = 511 116 | }; 117 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerPrivate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import 29 | #import 30 | 31 | /** 32 | * All GCDWebServer headers. 33 | */ 34 | 35 | #import "GCDWebServerHTTPStatusCodes.h" 36 | #import "GCDWebServerFunctions.h" 37 | 38 | #import "GCDWebServer.h" 39 | #import "GCDWebServerConnection.h" 40 | 41 | #import "GCDWebServerDataRequest.h" 42 | #import "GCDWebServerFileRequest.h" 43 | #import "GCDWebServerMultiPartFormRequest.h" 44 | #import "GCDWebServerURLEncodedFormRequest.h" 45 | 46 | #import "GCDWebServerDataResponse.h" 47 | #import "GCDWebServerErrorResponse.h" 48 | #import "GCDWebServerFileResponse.h" 49 | #import "GCDWebServerStreamedResponse.h" 50 | 51 | /** 52 | * Check if a custom logging facility should be used instead. 53 | */ 54 | 55 | #if defined(__GCDWEBSERVER_LOGGING_HEADER__) 56 | 57 | #define __GCDWEBSERVER_LOGGING_FACILITY_CUSTOM__ 58 | 59 | #import __GCDWEBSERVER_LOGGING_HEADER__ 60 | 61 | /** 62 | * Automatically detect if XLFacility is available and if so use it as a 63 | * logging facility. 64 | */ 65 | 66 | #elif defined(__has_include) && __has_include("XLFacilityMacros.h") 67 | 68 | #define __GCDWEBSERVER_LOGGING_FACILITY_XLFACILITY__ 69 | 70 | #undef XLOG_TAG 71 | #define XLOG_TAG @"gcdwebserver.internal" 72 | 73 | #import "XLFacilityMacros.h" 74 | 75 | #define GWS_LOG_DEBUG(...) XLOG_DEBUG(__VA_ARGS__) 76 | #define GWS_LOG_VERBOSE(...) XLOG_VERBOSE(__VA_ARGS__) 77 | #define GWS_LOG_INFO(...) XLOG_INFO(__VA_ARGS__) 78 | #define GWS_LOG_WARNING(...) XLOG_WARNING(__VA_ARGS__) 79 | #define GWS_LOG_ERROR(...) XLOG_ERROR(__VA_ARGS__) 80 | #define GWS_LOG_EXCEPTION(__EXCEPTION__) XLOG_EXCEPTION(__EXCEPTION__) 81 | 82 | #define GWS_DCHECK(__CONDITION__) XLOG_DEBUG_CHECK(__CONDITION__) 83 | #define GWS_DNOT_REACHED() XLOG_DEBUG_UNREACHABLE() 84 | 85 | /** 86 | * Automatically detect if CocoaLumberJack is available and if so use 87 | * it as a logging facility. 88 | */ 89 | 90 | #elif defined(__has_include) && __has_include("CocoaLumberjack/CocoaLumberjack.h") 91 | 92 | #import 93 | 94 | #define __GCDWEBSERVER_LOGGING_FACILITY_COCOALUMBERJACK__ 95 | 96 | #undef LOG_LEVEL_DEF 97 | #define LOG_LEVEL_DEF GCDWebServerLogLevel 98 | extern DDLogLevel GCDWebServerLogLevel; 99 | 100 | #define GWS_LOG_DEBUG(...) DDLogDebug(__VA_ARGS__) 101 | #define GWS_LOG_VERBOSE(...) DDLogVerbose(__VA_ARGS__) 102 | #define GWS_LOG_INFO(...) DDLogInfo(__VA_ARGS__) 103 | #define GWS_LOG_WARNING(...) DDLogWarn(__VA_ARGS__) 104 | #define GWS_LOG_ERROR(...) DDLogError(__VA_ARGS__) 105 | #define GWS_LOG_EXCEPTION(__EXCEPTION__) DDLogError(@"%@", __EXCEPTION__) 106 | 107 | /** 108 | * If all of the above fail, then use GCDWebServer built-in 109 | * logging facility. 110 | */ 111 | 112 | #else 113 | 114 | #define __GCDWEBSERVER_LOGGING_FACILITY_BUILTIN__ 115 | 116 | typedef NS_ENUM(int, GCDWebServerLoggingLevel) { 117 | kGCDWebServerLoggingLevel_Debug = 0, 118 | kGCDWebServerLoggingLevel_Verbose, 119 | kGCDWebServerLoggingLevel_Info, 120 | kGCDWebServerLoggingLevel_Warning, 121 | kGCDWebServerLoggingLevel_Error, 122 | kGCDWebServerLoggingLevel_Exception 123 | }; 124 | 125 | extern GCDWebServerLoggingLevel GCDWebServerLogLevel; 126 | extern void GCDWebServerLogMessage(GCDWebServerLoggingLevel level, NSString* format, ...) NS_FORMAT_FUNCTION(2, 3); 127 | 128 | #if DEBUG 129 | #define GWS_LOG_DEBUG(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Debug) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Debug, __VA_ARGS__); } while (0) 130 | #else 131 | #define GWS_LOG_DEBUG(...) 132 | #endif 133 | #define GWS_LOG_VERBOSE(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Verbose) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Verbose, __VA_ARGS__); } while (0) 134 | #define GWS_LOG_INFO(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Info) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Info, __VA_ARGS__); } while (0) 135 | #define GWS_LOG_WARNING(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Warning) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Warning, __VA_ARGS__); } while (0) 136 | #define GWS_LOG_ERROR(...) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Error) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Error, __VA_ARGS__); } while (0) 137 | #define GWS_LOG_EXCEPTION(__EXCEPTION__) do { if (GCDWebServerLogLevel <= kGCDWebServerLoggingLevel_Exception) GCDWebServerLogMessage(kGCDWebServerLoggingLevel_Exception, @"%@", __EXCEPTION__); } while (0) 138 | 139 | #endif 140 | 141 | /** 142 | * Consistency check macros used when building Debug only. 143 | */ 144 | 145 | #if !defined(GWS_DCHECK) || !defined(GWS_DNOT_REACHED) 146 | 147 | #if DEBUG 148 | 149 | #define GWS_DCHECK(__CONDITION__) \ 150 | do { \ 151 | if (!(__CONDITION__)) { \ 152 | abort(); \ 153 | } \ 154 | } while (0) 155 | #define GWS_DNOT_REACHED() abort() 156 | 157 | #else 158 | 159 | #define GWS_DCHECK(__CONDITION__) 160 | #define GWS_DNOT_REACHED() 161 | 162 | #endif 163 | 164 | #endif 165 | 166 | /** 167 | * GCDWebServer internal constants and APIs. 168 | */ 169 | 170 | #define kGCDWebServerDefaultMimeType @"application/octet-stream" 171 | #define kGCDWebServerGCDQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) 172 | #define kGCDWebServerErrorDomain @"GCDWebServerErrorDomain" 173 | 174 | static inline BOOL GCDWebServerIsValidByteRange(NSRange range) { 175 | return ((range.location != NSUIntegerMax) || (range.length > 0)); 176 | } 177 | 178 | static inline NSError* GCDWebServerMakePosixError(int code) { 179 | return [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithUTF8String:strerror(code)]}]; 180 | } 181 | 182 | extern void GCDWebServerInitializeFunctions(); 183 | extern NSString* GCDWebServerNormalizeHeaderValue(NSString* value); 184 | extern NSString* GCDWebServerTruncateHeaderValue(NSString* value); 185 | extern NSString* GCDWebServerExtractHeaderValueParameter(NSString* header, NSString* attribute); 186 | extern NSStringEncoding GCDWebServerStringEncodingFromCharset(NSString* charset); 187 | extern BOOL GCDWebServerIsTextContentType(NSString* type); 188 | extern NSString* GCDWebServerDescribeData(NSData* data, NSString* contentType); 189 | extern NSString* GCDWebServerComputeMD5Digest(NSString* format, ...) NS_FORMAT_FUNCTION(1,2); 190 | extern NSString* GCDWebServerStringFromSockAddr(const struct sockaddr* addr, BOOL includeService); 191 | 192 | @interface GCDWebServerConnection () 193 | - (id)initWithServer:(GCDWebServer*)server localAddress:(NSData*)localAddress remoteAddress:(NSData*)remoteAddress socket:(CFSocketNativeHandle)socket; 194 | @end 195 | 196 | @interface GCDWebServer () 197 | @property(nonatomic, readonly) NSArray* handlers; 198 | @property(nonatomic, readonly) NSString* serverName; 199 | @property(nonatomic, readonly) NSString* authenticationRealm; 200 | @property(nonatomic, readonly) NSDictionary* authenticationBasicAccounts; 201 | @property(nonatomic, readonly) NSDictionary* authenticationDigestAccounts; 202 | @property(nonatomic, readonly) BOOL shouldAutomaticallyMapHEADToGET; 203 | - (void)willStartConnection:(GCDWebServerConnection*)connection; 204 | - (void)didEndConnection:(GCDWebServerConnection*)connection; 205 | @end 206 | 207 | @interface GCDWebServerHandler : NSObject 208 | @property(nonatomic, readonly) GCDWebServerMatchBlock matchBlock; 209 | @property(nonatomic, readonly) GCDWebServerAsyncProcessBlock asyncProcessBlock; 210 | @end 211 | 212 | @interface GCDWebServerRequest () 213 | @property(nonatomic, readonly) BOOL usesChunkedTransferEncoding; 214 | @property(nonatomic, readwrite) NSData* localAddressData; 215 | @property(nonatomic, readwrite) NSData* remoteAddressData; 216 | - (void)prepareForWriting; 217 | - (BOOL)performOpen:(NSError**)error; 218 | - (BOOL)performWriteData:(NSData*)data error:(NSError**)error; 219 | - (BOOL)performClose:(NSError**)error; 220 | - (void)setAttribute:(id)attribute forKey:(NSString*)key; 221 | @end 222 | 223 | @interface GCDWebServerResponse () 224 | @property(nonatomic, readonly) NSDictionary* additionalHeaders; 225 | @property(nonatomic, readonly) BOOL usesChunkedTransferEncoding; 226 | - (void)prepareForReading; 227 | - (BOOL)performOpen:(NSError**)error; 228 | - (void)performReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block; 229 | - (void)performClose; 230 | @end 231 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import 29 | 30 | /** 31 | * Attribute key to retrieve an NSArray containing NSStrings from a GCDWebServerRequest 32 | * with the contents of any regular expression captures done on the request path. 33 | * 34 | * @warning This attribute will only be set on the request if adding a handler using 35 | * -addHandlerForMethod:pathRegex:requestClass:processBlock:. 36 | */ 37 | extern NSString* const GCDWebServerRequestAttribute_RegexCaptures; 38 | 39 | /** 40 | * This protocol is used by the GCDWebServerConnection to communicate with 41 | * the GCDWebServerRequest and write the received HTTP body data. 42 | * 43 | * Note that multiple GCDWebServerBodyWriter objects can be chained together 44 | * internally e.g. to automatically decode gzip encoded content before 45 | * passing it on to the GCDWebServerRequest. 46 | * 47 | * @warning These methods can be called on any GCD thread. 48 | */ 49 | @protocol GCDWebServerBodyWriter 50 | 51 | /** 52 | * This method is called before any body data is received. 53 | * 54 | * It should return YES on success or NO on failure and set the "error" argument 55 | * which is guaranteed to be non-NULL. 56 | */ 57 | - (BOOL)open:(NSError**)error; 58 | 59 | /** 60 | * This method is called whenever body data has been received. 61 | * 62 | * It should return YES on success or NO on failure and set the "error" argument 63 | * which is guaranteed to be non-NULL. 64 | */ 65 | - (BOOL)writeData:(NSData*)data error:(NSError**)error; 66 | 67 | /** 68 | * This method is called after all body data has been received. 69 | * 70 | * It should return YES on success or NO on failure and set the "error" argument 71 | * which is guaranteed to be non-NULL. 72 | */ 73 | - (BOOL)close:(NSError**)error; 74 | 75 | @end 76 | 77 | /** 78 | * The GCDWebServerRequest class is instantiated by the GCDWebServerConnection 79 | * after the HTTP headers have been received. Each instance wraps a single HTTP 80 | * request. If a body is present, the methods from the GCDWebServerBodyWriter 81 | * protocol will be called by the GCDWebServerConnection to receive it. 82 | * 83 | * The default implementation of the GCDWebServerBodyWriter protocol on the class 84 | * simply ignores the body data. 85 | * 86 | * @warning GCDWebServerRequest instances can be created and used on any GCD thread. 87 | */ 88 | @interface GCDWebServerRequest : NSObject 89 | 90 | /** 91 | * Returns the HTTP method for the request. 92 | */ 93 | @property(nonatomic, readonly) NSString* method; 94 | 95 | /** 96 | * Returns the URL for the request. 97 | */ 98 | @property(nonatomic, readonly) NSURL* URL; 99 | 100 | /** 101 | * Returns the HTTP headers for the request. 102 | */ 103 | @property(nonatomic, readonly) NSDictionary* headers; 104 | 105 | /** 106 | * Returns the path component of the URL for the request. 107 | */ 108 | @property(nonatomic, readonly) NSString* path; 109 | 110 | /** 111 | * Returns the parsed and unescaped query component of the URL for the request. 112 | * 113 | * @warning This property will be nil if there is no query in the URL. 114 | */ 115 | @property(nonatomic, readonly) NSDictionary* query; 116 | 117 | /** 118 | * Returns the content type for the body of the request parsed from the 119 | * "Content-Type" header. 120 | * 121 | * This property will be nil if the request has no body or set to 122 | * "application/octet-stream" if a body is present but there was no 123 | * "Content-Type" header. 124 | */ 125 | @property(nonatomic, readonly) NSString* contentType; 126 | 127 | /** 128 | * Returns the content length for the body of the request parsed from the 129 | * "Content-Length" header. 130 | * 131 | * This property will be set to "NSUIntegerMax" if the request has no body or 132 | * if there is a body but no "Content-Length" header, typically because 133 | * chunked transfer encoding is used. 134 | */ 135 | @property(nonatomic, readonly) NSUInteger contentLength; 136 | 137 | /** 138 | * Returns the parsed "If-Modified-Since" header or nil if absent or malformed. 139 | */ 140 | @property(nonatomic, readonly) NSDate* ifModifiedSince; 141 | 142 | /** 143 | * Returns the parsed "If-None-Match" header or nil if absent or malformed. 144 | */ 145 | @property(nonatomic, readonly) NSString* ifNoneMatch; 146 | 147 | /** 148 | * Returns the parsed "Range" header or (NSUIntegerMax, 0) if absent or malformed. 149 | * The range will be set to (offset, length) if expressed from the beginning 150 | * of the entity body, or (NSUIntegerMax, length) if expressed from its end. 151 | */ 152 | @property(nonatomic, readonly) NSRange byteRange; 153 | 154 | /** 155 | * Returns YES if the client supports gzip content encoding according to the 156 | * "Accept-Encoding" header. 157 | */ 158 | @property(nonatomic, readonly) BOOL acceptsGzipContentEncoding; 159 | 160 | /** 161 | * Returns the address of the local peer (i.e. server) for the request 162 | * as a raw "struct sockaddr". 163 | */ 164 | @property(nonatomic, readonly) NSData* localAddressData; 165 | 166 | /** 167 | * Returns the address of the local peer (i.e. server) for the request 168 | * as a string. 169 | */ 170 | @property(nonatomic, readonly) NSString* localAddressString; 171 | 172 | /** 173 | * Returns the address of the remote peer (i.e. client) for the request 174 | * as a raw "struct sockaddr". 175 | */ 176 | @property(nonatomic, readonly) NSData* remoteAddressData; 177 | 178 | /** 179 | * Returns the address of the remote peer (i.e. client) for the request 180 | * as a string. 181 | */ 182 | @property(nonatomic, readonly) NSString* remoteAddressString; 183 | 184 | /** 185 | * This method is the designated initializer for the class. 186 | */ 187 | - (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers path:(NSString*)path query:(NSDictionary*)query; 188 | 189 | /** 190 | * Convenience method that checks if the contentType property is defined. 191 | */ 192 | - (BOOL)hasBody; 193 | 194 | /** 195 | * Convenience method that checks if the byteRange property is defined. 196 | */ 197 | - (BOOL)hasByteRange; 198 | 199 | /** 200 | * Retrieves an attribute associated with this request using the given key. 201 | * 202 | * @return The attribute value for the key. 203 | */ 204 | - (id)attributeForKey:(NSString*)key; 205 | 206 | @end 207 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import 29 | 30 | /** 31 | * The GCDWebServerBodyReaderCompletionBlock is passed by GCDWebServer to the 32 | * GCDWebServerBodyReader object when reading data from it asynchronously. 33 | */ 34 | typedef void (^GCDWebServerBodyReaderCompletionBlock)(NSData* data, NSError* error); 35 | 36 | /** 37 | * This protocol is used by the GCDWebServerConnection to communicate with 38 | * the GCDWebServerResponse and read the HTTP body data to send. 39 | * 40 | * Note that multiple GCDWebServerBodyReader objects can be chained together 41 | * internally e.g. to automatically apply gzip encoding to the content before 42 | * passing it on to the GCDWebServerResponse. 43 | * 44 | * @warning These methods can be called on any GCD thread. 45 | */ 46 | @protocol GCDWebServerBodyReader 47 | 48 | @required 49 | 50 | /** 51 | * This method is called before any body data is sent. 52 | * 53 | * It should return YES on success or NO on failure and set the "error" argument 54 | * which is guaranteed to be non-NULL. 55 | */ 56 | - (BOOL)open:(NSError**)error; 57 | 58 | /** 59 | * This method is called whenever body data is sent. 60 | * 61 | * It should return a non-empty NSData if there is body data available, 62 | * or an empty NSData there is no more body data, or nil on error and set 63 | * the "error" argument which is guaranteed to be non-NULL. 64 | */ 65 | - (NSData*)readData:(NSError**)error; 66 | 67 | /** 68 | * This method is called after all body data has been sent. 69 | */ 70 | - (void)close; 71 | 72 | @optional 73 | 74 | /** 75 | * If this method is implemented, it will be preferred over -readData:. 76 | * 77 | * It must call the passed block when data is available, passing a non-empty 78 | * NSData if there is body data available, or an empty NSData there is no more 79 | * body data, or nil on error and pass an NSError along. 80 | */ 81 | - (void)asyncReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block; 82 | 83 | @end 84 | 85 | /** 86 | * The GCDWebServerResponse class is used to wrap a single HTTP response. 87 | * It is instantiated by the handler of the GCDWebServer that handled the request. 88 | * If a body is present, the methods from the GCDWebServerBodyReader protocol 89 | * will be called by the GCDWebServerConnection to send it. 90 | * 91 | * The default implementation of the GCDWebServerBodyReader protocol 92 | * on the class simply returns an empty body. 93 | * 94 | * @warning GCDWebServerResponse instances can be created and used on any GCD thread. 95 | */ 96 | @interface GCDWebServerResponse : NSObject 97 | 98 | /** 99 | * Sets the content type for the body of the response. 100 | * 101 | * The default value is nil i.e. the response has no body. 102 | * 103 | * @warning This property must be set if a body is present. 104 | */ 105 | @property(nonatomic, copy) NSString* contentType; 106 | 107 | /** 108 | * Sets the content length for the body of the response. If a body is present 109 | * but this property is set to "NSUIntegerMax", this means the length of the body 110 | * cannot be known ahead of time. Chunked transfer encoding will be 111 | * automatically enabled by the GCDWebServerConnection to comply with HTTP/1.1 112 | * specifications. 113 | * 114 | * The default value is "NSUIntegerMax" i.e. the response has no body or its length 115 | * is undefined. 116 | */ 117 | @property(nonatomic) NSUInteger contentLength; 118 | 119 | /** 120 | * Sets the HTTP status code for the response. 121 | * 122 | * The default value is 200 i.e. "OK". 123 | */ 124 | @property(nonatomic) NSInteger statusCode; 125 | 126 | /** 127 | * Sets the caching hint for the response using the "Cache-Control" header. 128 | * This value is expressed in seconds. 129 | * 130 | * The default value is 0 i.e. "no-cache". 131 | */ 132 | @property(nonatomic) NSUInteger cacheControlMaxAge; 133 | 134 | /** 135 | * Sets the last modified date for the response using the "Last-Modified" header. 136 | * 137 | * The default value is nil. 138 | */ 139 | @property(nonatomic, retain) NSDate* lastModifiedDate; 140 | 141 | /** 142 | * Sets the ETag for the response using the "ETag" header. 143 | * 144 | * The default value is nil. 145 | */ 146 | @property(nonatomic, copy) NSString* eTag; 147 | 148 | /** 149 | * Enables gzip encoding for the response body. 150 | * 151 | * The default value is NO. 152 | * 153 | * @warning Enabling gzip encoding will remove any "Content-Length" header 154 | * since the length of the body is not known anymore. The client will still 155 | * be able to determine the body length when connection is closed per 156 | * HTTP/1.1 specifications. 157 | */ 158 | @property(nonatomic, getter=isGZipContentEncodingEnabled) BOOL gzipContentEncodingEnabled; 159 | 160 | /** 161 | * Creates an empty response. 162 | */ 163 | + (instancetype)response; 164 | 165 | /** 166 | * This method is the designated initializer for the class. 167 | */ 168 | - (instancetype)init; 169 | 170 | /** 171 | * Sets an additional HTTP header on the response. 172 | * Pass a nil value to remove an additional header. 173 | * 174 | * @warning Do not attempt to override the primary headers used 175 | * by GCDWebServerResponse like "Content-Type", "ETag", etc... 176 | */ 177 | - (void)setValue:(NSString*)value forAdditionalHeader:(NSString*)header; 178 | 179 | /** 180 | * Convenience method that checks if the contentType property is defined. 181 | */ 182 | - (BOOL)hasBody; 183 | 184 | @end 185 | 186 | @interface GCDWebServerResponse (Extensions) 187 | 188 | /** 189 | * Creates a empty response with a specific HTTP status code. 190 | */ 191 | + (instancetype)responseWithStatusCode:(NSInteger)statusCode; 192 | 193 | /** 194 | * Creates an HTTP redirect response to a new URL. 195 | */ 196 | + (instancetype)responseWithRedirect:(NSURL*)location permanent:(BOOL)permanent; 197 | 198 | /** 199 | * Initializes an empty response with a specific HTTP status code. 200 | */ 201 | - (instancetype)initWithStatusCode:(NSInteger)statusCode; 202 | 203 | /** 204 | * Initializes an HTTP redirect response to a new URL. 205 | */ 206 | - (instancetype)initWithRedirect:(NSURL*)location permanent:(BOOL)permanent; 207 | 208 | @end 209 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Core/GCDWebServerResponse.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import 33 | 34 | #import "GCDWebServerPrivate.h" 35 | 36 | #define kZlibErrorDomain @"ZlibErrorDomain" 37 | #define kGZipInitialBufferSize (256 * 1024) 38 | 39 | @interface GCDWebServerBodyEncoder : NSObject 40 | - (id)initWithResponse:(GCDWebServerResponse*)response reader:(id)reader; 41 | @end 42 | 43 | @interface GCDWebServerGZipEncoder : GCDWebServerBodyEncoder 44 | @end 45 | 46 | @interface GCDWebServerBodyEncoder () { 47 | @private 48 | GCDWebServerResponse* __unsafe_unretained _response; 49 | id __unsafe_unretained _reader; 50 | } 51 | @end 52 | 53 | @implementation GCDWebServerBodyEncoder 54 | 55 | - (id)initWithResponse:(GCDWebServerResponse*)response reader:(id)reader { 56 | if ((self = [super init])) { 57 | _response = response; 58 | _reader = reader; 59 | } 60 | return self; 61 | } 62 | 63 | - (BOOL)open:(NSError**)error { 64 | return [_reader open:error]; 65 | } 66 | 67 | - (NSData*)readData:(NSError**)error { 68 | return [_reader readData:error]; 69 | } 70 | 71 | - (void)close { 72 | [_reader close]; 73 | } 74 | 75 | @end 76 | 77 | @interface GCDWebServerGZipEncoder () { 78 | @private 79 | z_stream _stream; 80 | BOOL _finished; 81 | } 82 | @end 83 | 84 | @implementation GCDWebServerGZipEncoder 85 | 86 | - (id)initWithResponse:(GCDWebServerResponse*)response reader:(id)reader { 87 | if ((self = [super initWithResponse:response reader:reader])) { 88 | response.contentLength = NSUIntegerMax; // Make sure "Content-Length" header is not set since we don't know it 89 | [response setValue:@"gzip" forAdditionalHeader:@"Content-Encoding"]; 90 | } 91 | return self; 92 | } 93 | 94 | - (BOOL)open:(NSError**)error { 95 | int result = deflateInit2(&_stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); 96 | if (result != Z_OK) { 97 | if (error) { 98 | *error = [NSError errorWithDomain:kZlibErrorDomain code:result userInfo:nil]; 99 | } 100 | return NO; 101 | } 102 | if (![super open:error]) { 103 | deflateEnd(&_stream); 104 | return NO; 105 | } 106 | return YES; 107 | } 108 | 109 | - (NSData*)readData:(NSError**)error { 110 | NSMutableData* encodedData; 111 | if (_finished) { 112 | encodedData = [[NSMutableData alloc] init]; 113 | } else { 114 | encodedData = [[NSMutableData alloc] initWithLength:kGZipInitialBufferSize]; 115 | if (encodedData == nil) { 116 | GWS_DNOT_REACHED(); 117 | return nil; 118 | } 119 | NSUInteger length = 0; 120 | do { 121 | NSData* data = [super readData:error]; 122 | if (data == nil) { 123 | return nil; 124 | } 125 | _stream.next_in = (Bytef*)data.bytes; 126 | _stream.avail_in = (uInt)data.length; 127 | while (1) { 128 | NSUInteger maxLength = encodedData.length - length; 129 | _stream.next_out = (Bytef*)((char*)encodedData.mutableBytes + length); 130 | _stream.avail_out = (uInt)maxLength; 131 | int result = deflate(&_stream, data.length ? Z_NO_FLUSH : Z_FINISH); 132 | if (result == Z_STREAM_END) { 133 | _finished = YES; 134 | } else if (result != Z_OK) { 135 | if (error) { 136 | *error = [NSError errorWithDomain:kZlibErrorDomain code:result userInfo:nil]; 137 | } 138 | return nil; 139 | } 140 | length += maxLength - _stream.avail_out; 141 | if (_stream.avail_out > 0) { 142 | break; 143 | } 144 | encodedData.length = 2 * encodedData.length; // zlib has used all the output buffer so resize it and try again in case more data is available 145 | } 146 | GWS_DCHECK(_stream.avail_in == 0); 147 | } while (length == 0); // Make sure we don't return an empty NSData if not in finished state 148 | encodedData.length = length; 149 | } 150 | return encodedData; 151 | } 152 | 153 | - (void)close { 154 | deflateEnd(&_stream); 155 | [super close]; 156 | } 157 | 158 | @end 159 | 160 | @interface GCDWebServerResponse () { 161 | @private 162 | NSString* _type; 163 | NSUInteger _length; 164 | NSInteger _status; 165 | NSUInteger _maxAge; 166 | NSDate* _lastModified; 167 | NSString* _eTag; 168 | NSMutableDictionary* _headers; 169 | BOOL _chunked; 170 | BOOL _gzipped; 171 | 172 | BOOL _opened; 173 | NSMutableArray* _encoders; 174 | id __unsafe_unretained _reader; 175 | } 176 | @end 177 | 178 | @implementation GCDWebServerResponse 179 | 180 | @synthesize contentType=_type, contentLength=_length, statusCode=_status, cacheControlMaxAge=_maxAge, lastModifiedDate=_lastModified, eTag=_eTag, 181 | gzipContentEncodingEnabled=_gzipped, additionalHeaders=_headers; 182 | 183 | + (instancetype)response { 184 | return [[[self class] alloc] init]; 185 | } 186 | 187 | - (instancetype)init { 188 | if ((self = [super init])) { 189 | _type = nil; 190 | _length = NSUIntegerMax; 191 | _status = kGCDWebServerHTTPStatusCode_OK; 192 | _maxAge = 0; 193 | _headers = [[NSMutableDictionary alloc] init]; 194 | _encoders = [[NSMutableArray alloc] init]; 195 | } 196 | return self; 197 | } 198 | 199 | - (void)setValue:(NSString*)value forAdditionalHeader:(NSString*)header { 200 | [_headers setValue:value forKey:header]; 201 | } 202 | 203 | - (BOOL)hasBody { 204 | return _type ? YES : NO; 205 | } 206 | 207 | - (BOOL)usesChunkedTransferEncoding { 208 | return (_type != nil) && (_length == NSUIntegerMax); 209 | } 210 | 211 | - (BOOL)open:(NSError**)error { 212 | return YES; 213 | } 214 | 215 | - (NSData*)readData:(NSError**)error { 216 | return [NSData data]; 217 | } 218 | 219 | - (void)close { 220 | ; 221 | } 222 | 223 | - (void)prepareForReading { 224 | _reader = self; 225 | if (_gzipped) { 226 | GCDWebServerGZipEncoder* encoder = [[GCDWebServerGZipEncoder alloc] initWithResponse:self reader:_reader]; 227 | [_encoders addObject:encoder]; 228 | _reader = encoder; 229 | } 230 | } 231 | 232 | - (BOOL)performOpen:(NSError**)error { 233 | GWS_DCHECK(_type); 234 | GWS_DCHECK(_reader); 235 | if (_opened) { 236 | GWS_DNOT_REACHED(); 237 | return NO; 238 | } 239 | _opened = YES; 240 | return [_reader open:error]; 241 | } 242 | 243 | - (void)performReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block { 244 | if ([_reader respondsToSelector:@selector(asyncReadDataWithCompletion:)]) { 245 | [_reader asyncReadDataWithCompletion:[block copy]]; 246 | } else { 247 | NSError* error = nil; 248 | NSData* data = [_reader readData:&error]; 249 | block(data, error); 250 | } 251 | } 252 | 253 | - (void)performClose { 254 | GWS_DCHECK(_opened); 255 | [_reader close]; 256 | } 257 | 258 | - (NSString*)description { 259 | NSMutableString* description = [NSMutableString stringWithFormat:@"Status Code = %i", (int)_status]; 260 | if (_type) { 261 | [description appendFormat:@"\nContent Type = %@", _type]; 262 | } 263 | if (_length != NSUIntegerMax) { 264 | [description appendFormat:@"\nContent Length = %lu", (unsigned long)_length]; 265 | } 266 | [description appendFormat:@"\nCache Control Max Age = %lu", (unsigned long)_maxAge]; 267 | if (_lastModified) { 268 | [description appendFormat:@"\nLast Modified Date = %@", _lastModified]; 269 | } 270 | if (_eTag) { 271 | [description appendFormat:@"\nETag = %@", _eTag]; 272 | } 273 | if (_headers.count) { 274 | [description appendString:@"\n"]; 275 | for (NSString* header in [[_headers allKeys] sortedArrayUsingSelector:@selector(compare:)]) { 276 | [description appendFormat:@"\n%@: %@", header, [_headers objectForKey:header]]; 277 | } 278 | } 279 | return description; 280 | } 281 | 282 | @end 283 | 284 | @implementation GCDWebServerResponse (Extensions) 285 | 286 | + (instancetype)responseWithStatusCode:(NSInteger)statusCode { 287 | return [[self alloc] initWithStatusCode:statusCode]; 288 | } 289 | 290 | + (instancetype)responseWithRedirect:(NSURL*)location permanent:(BOOL)permanent { 291 | return [[self alloc] initWithRedirect:location permanent:permanent]; 292 | } 293 | 294 | - (instancetype)initWithStatusCode:(NSInteger)statusCode { 295 | if ((self = [self init])) { 296 | self.statusCode = statusCode; 297 | } 298 | return self; 299 | } 300 | 301 | - (instancetype)initWithRedirect:(NSURL*)location permanent:(BOOL)permanent { 302 | if ((self = [self init])) { 303 | self.statusCode = permanent ? kGCDWebServerHTTPStatusCode_MovedPermanently : kGCDWebServerHTTPStatusCode_TemporaryRedirect; 304 | [self setValue:[location absoluteString] forAdditionalHeader:@"Location"]; 305 | } 306 | return self; 307 | } 308 | 309 | @end 310 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerDataRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerRequest.h" 29 | 30 | /** 31 | * The GCDWebServerDataRequest subclass of GCDWebServerRequest stores the body 32 | * of the HTTP request in memory. 33 | */ 34 | @interface GCDWebServerDataRequest : GCDWebServerRequest 35 | 36 | /** 37 | * Returns the data for the request body. 38 | */ 39 | @property(nonatomic, readonly) NSData* data; 40 | 41 | @end 42 | 43 | @interface GCDWebServerDataRequest (Extensions) 44 | 45 | /** 46 | * Returns the data for the request body interpreted as text. If the content 47 | * type of the body is not a text one, or if an error occurs, nil is returned. 48 | * 49 | * The text encoding used to interpret the data is extracted from the 50 | * "Content-Type" header or defaults to UTF-8. 51 | */ 52 | @property(nonatomic, readonly) NSString* text; 53 | 54 | /** 55 | * Returns the data for the request body interpreted as a JSON object. If the 56 | * content type of the body is not JSON, or if an error occurs, nil is returned. 57 | */ 58 | @property(nonatomic, readonly) id jsonObject; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerDataRequest.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @interface GCDWebServerDataRequest () { 35 | @private 36 | NSMutableData* _data; 37 | 38 | NSString* _text; 39 | id _jsonObject; 40 | } 41 | @end 42 | 43 | @implementation GCDWebServerDataRequest 44 | 45 | @synthesize data=_data; 46 | 47 | - (BOOL)open:(NSError**)error { 48 | if (self.contentLength != NSUIntegerMax) { 49 | _data = [[NSMutableData alloc] initWithCapacity:self.contentLength]; 50 | } else { 51 | _data = [[NSMutableData alloc] init]; 52 | } 53 | if (_data == nil) { 54 | if (error) { 55 | *error = [NSError errorWithDomain:kGCDWebServerErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Failed allocating memory"}]; 56 | } 57 | return NO; 58 | } 59 | return YES; 60 | } 61 | 62 | - (BOOL)writeData:(NSData*)data error:(NSError**)error { 63 | [_data appendData:data]; 64 | return YES; 65 | } 66 | 67 | - (BOOL)close:(NSError**)error { 68 | return YES; 69 | } 70 | 71 | - (NSString*)description { 72 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 73 | if (_data) { 74 | [description appendString:@"\n\n"]; 75 | [description appendString:GCDWebServerDescribeData(_data, self.contentType)]; 76 | } 77 | return description; 78 | } 79 | 80 | @end 81 | 82 | @implementation GCDWebServerDataRequest (Extensions) 83 | 84 | - (NSString*)text { 85 | if (_text == nil) { 86 | if ([self.contentType hasPrefix:@"text/"]) { 87 | NSString* charset = GCDWebServerExtractHeaderValueParameter(self.contentType, @"charset"); 88 | _text = [[NSString alloc] initWithData:self.data encoding:GCDWebServerStringEncodingFromCharset(charset)]; 89 | } else { 90 | GWS_DNOT_REACHED(); 91 | } 92 | } 93 | return _text; 94 | } 95 | 96 | - (id)jsonObject { 97 | if (_jsonObject == nil) { 98 | NSString* mimeType = GCDWebServerTruncateHeaderValue(self.contentType); 99 | if ([mimeType isEqualToString:@"application/json"] || [mimeType isEqualToString:@"text/json"] || [mimeType isEqualToString:@"text/javascript"]) { 100 | _jsonObject = [NSJSONSerialization JSONObjectWithData:_data options:0 error:NULL]; 101 | } else { 102 | GWS_DNOT_REACHED(); 103 | } 104 | } 105 | return _jsonObject; 106 | } 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerRequest.h" 29 | 30 | /** 31 | * The GCDWebServerFileRequest subclass of GCDWebServerRequest stores the body 32 | * of the HTTP request to a file on disk. 33 | */ 34 | @interface GCDWebServerFileRequest : GCDWebServerRequest 35 | 36 | /** 37 | * Returns the path to the temporary file containing the request body. 38 | * 39 | * @warning This temporary file will be automatically deleted when the 40 | * GCDWebServerFileRequest is deallocated. If you want to preserve this file, 41 | * you must move it to a different location beforehand. 42 | */ 43 | @property(nonatomic, readonly) NSString* temporaryPath; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @interface GCDWebServerFileRequest () { 35 | @private 36 | NSString* _temporaryPath; 37 | int _file; 38 | } 39 | @end 40 | 41 | @implementation GCDWebServerFileRequest 42 | 43 | @synthesize temporaryPath=_temporaryPath; 44 | 45 | - (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers path:(NSString*)path query:(NSDictionary*)query { 46 | if ((self = [super initWithMethod:method url:url headers:headers path:path query:query])) { 47 | _temporaryPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]]; 48 | } 49 | return self; 50 | } 51 | 52 | - (void)dealloc { 53 | unlink([_temporaryPath fileSystemRepresentation]); 54 | } 55 | 56 | - (BOOL)open:(NSError**)error { 57 | _file = open([_temporaryPath fileSystemRepresentation], O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); 58 | if (_file <= 0) { 59 | if (error) { 60 | *error = GCDWebServerMakePosixError(errno); 61 | } 62 | return NO; 63 | } 64 | return YES; 65 | } 66 | 67 | - (BOOL)writeData:(NSData*)data error:(NSError**)error { 68 | if (write(_file, data.bytes, data.length) != (ssize_t)data.length) { 69 | if (error) { 70 | *error = GCDWebServerMakePosixError(errno); 71 | } 72 | return NO; 73 | } 74 | return YES; 75 | } 76 | 77 | - (BOOL)close:(NSError**)error { 78 | if (close(_file) < 0) { 79 | if (error) { 80 | *error = GCDWebServerMakePosixError(errno); 81 | } 82 | return NO; 83 | } 84 | #ifdef __GCDWEBSERVER_ENABLE_TESTING__ 85 | NSString* creationDateHeader = [self.headers objectForKey:@"X-GCDWebServer-CreationDate"]; 86 | if (creationDateHeader) { 87 | NSDate* date = GCDWebServerParseISO8601(creationDateHeader); 88 | if (!date || ![[NSFileManager defaultManager] setAttributes:@{NSFileCreationDate: date} ofItemAtPath:_temporaryPath error:error]) { 89 | return NO; 90 | } 91 | } 92 | NSString* modifiedDateHeader = [self.headers objectForKey:@"X-GCDWebServer-ModifiedDate"]; 93 | if (modifiedDateHeader) { 94 | NSDate* date = GCDWebServerParseRFC822(modifiedDateHeader); 95 | if (!date || ![[NSFileManager defaultManager] setAttributes:@{NSFileModificationDate: date} ofItemAtPath:_temporaryPath error:error]) { 96 | return NO; 97 | } 98 | } 99 | #endif 100 | return YES; 101 | } 102 | 103 | - (NSString*)description { 104 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 105 | [description appendFormat:@"\n\n{%@}", _temporaryPath]; 106 | return description; 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerRequest.h" 29 | 30 | /** 31 | * The GCDWebServerMultiPart class is an abstract class that wraps the content 32 | * of a part. 33 | */ 34 | @interface GCDWebServerMultiPart : NSObject 35 | 36 | /** 37 | * Returns the control name retrieved from the part headers. 38 | */ 39 | @property(nonatomic, readonly) NSString* controlName; 40 | 41 | /** 42 | * Returns the content type retrieved from the part headers or "text/plain" 43 | * if not available (per HTTP specifications). 44 | */ 45 | @property(nonatomic, readonly) NSString* contentType; 46 | 47 | /** 48 | * Returns the MIME type component of the content type for the part. 49 | */ 50 | @property(nonatomic, readonly) NSString* mimeType; 51 | 52 | @end 53 | 54 | /** 55 | * The GCDWebServerMultiPartArgument subclass of GCDWebServerMultiPart wraps 56 | * the content of a part as data in memory. 57 | */ 58 | @interface GCDWebServerMultiPartArgument : GCDWebServerMultiPart 59 | 60 | /** 61 | * Returns the data for the part. 62 | */ 63 | @property(nonatomic, readonly) NSData* data; 64 | 65 | /** 66 | * Returns the data for the part interpreted as text. If the content 67 | * type of the part is not a text one, or if an error occurs, nil is returned. 68 | * 69 | * The text encoding used to interpret the data is extracted from the 70 | * "Content-Type" header or defaults to UTF-8. 71 | */ 72 | @property(nonatomic, readonly) NSString* string; 73 | 74 | @end 75 | 76 | /** 77 | * The GCDWebServerMultiPartFile subclass of GCDWebServerMultiPart wraps 78 | * the content of a part as a file on disk. 79 | */ 80 | @interface GCDWebServerMultiPartFile : GCDWebServerMultiPart 81 | 82 | /** 83 | * Returns the file name retrieved from the part headers. 84 | */ 85 | @property(nonatomic, readonly) NSString* fileName; 86 | 87 | /** 88 | * Returns the path to the temporary file containing the part data. 89 | * 90 | * @warning This temporary file will be automatically deleted when the 91 | * GCDWebServerMultiPartFile is deallocated. If you want to preserve this file, 92 | * you must move it to a different location beforehand. 93 | */ 94 | @property(nonatomic, readonly) NSString* temporaryPath; 95 | 96 | @end 97 | 98 | /** 99 | * The GCDWebServerMultiPartFormRequest subclass of GCDWebServerRequest 100 | * parses the body of the HTTP request as a multipart encoded form. 101 | */ 102 | @interface GCDWebServerMultiPartFormRequest : GCDWebServerRequest 103 | 104 | /** 105 | * Returns the argument parts from the multipart encoded form as 106 | * name / GCDWebServerMultiPartArgument pairs. 107 | */ 108 | @property(nonatomic, readonly) NSArray* arguments; 109 | 110 | /** 111 | * Returns the files parts from the multipart encoded form as 112 | * name / GCDWebServerMultiPartFile pairs. 113 | */ 114 | @property(nonatomic, readonly) NSArray* files; 115 | 116 | /** 117 | * Returns the MIME type for multipart encoded forms 118 | * i.e. "multipart/form-data". 119 | */ 120 | + (NSString*)mimeType; 121 | 122 | /** 123 | * Returns the first argument for a given control name or nil if not found. 124 | */ 125 | - (GCDWebServerMultiPartArgument*)firstArgumentForControlName:(NSString*)name; 126 | 127 | /** 128 | * Returns the first file for a given control name or nil if not found. 129 | */ 130 | - (GCDWebServerMultiPartFile*)firstFileForControlName:(NSString*)name; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerDataRequest.h" 29 | 30 | /** 31 | * The GCDWebServerURLEncodedFormRequest subclass of GCDWebServerRequest 32 | * parses the body of the HTTP request as a URL encoded form using 33 | * GCDWebServerParseURLEncodedForm(). 34 | */ 35 | @interface GCDWebServerURLEncodedFormRequest : GCDWebServerDataRequest 36 | 37 | /** 38 | * Returns the unescaped control names and values for the URL encoded form. 39 | * 40 | * The text encoding used to interpret the data is extracted from the 41 | * "Content-Type" header or defaults to UTF-8. 42 | */ 43 | @property(nonatomic, readonly) NSDictionary* arguments; 44 | 45 | /** 46 | * Returns the MIME type for URL encoded forms 47 | * i.e. "application/x-www-form-urlencoded". 48 | */ 49 | + (NSString*)mimeType; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @interface GCDWebServerURLEncodedFormRequest () { 35 | @private 36 | NSDictionary* _arguments; 37 | } 38 | @end 39 | 40 | @implementation GCDWebServerURLEncodedFormRequest 41 | 42 | @synthesize arguments=_arguments; 43 | 44 | + (NSString*)mimeType { 45 | return @"application/x-www-form-urlencoded"; 46 | } 47 | 48 | - (BOOL)close:(NSError**)error { 49 | if (![super close:error]) { 50 | return NO; 51 | } 52 | 53 | NSString* charset = GCDWebServerExtractHeaderValueParameter(self.contentType, @"charset"); 54 | NSString* string = [[NSString alloc] initWithData:self.data encoding:GCDWebServerStringEncodingFromCharset(charset)]; 55 | _arguments = GCDWebServerParseURLEncodedForm(string); 56 | GWS_DCHECK(_arguments); 57 | 58 | return YES; 59 | } 60 | 61 | - (NSString*)description { 62 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 63 | [description appendString:@"\n"]; 64 | for (NSString* argument in [[_arguments allKeys] sortedArrayUsingSelector:@selector(compare:)]) { 65 | [description appendFormat:@"\n%@ = %@", argument, [_arguments objectForKey:argument]]; 66 | } 67 | return description; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerResponse.h" 29 | 30 | /** 31 | * The GCDWebServerDataResponse subclass of GCDWebServerResponse reads the body 32 | * of the HTTP response from memory. 33 | */ 34 | @interface GCDWebServerDataResponse : GCDWebServerResponse 35 | 36 | /** 37 | * Creates a response with data in memory and a given content type. 38 | */ 39 | + (instancetype)responseWithData:(NSData*)data contentType:(NSString*)type; 40 | 41 | /** 42 | * This method is the designated initializer for the class. 43 | */ 44 | - (instancetype)initWithData:(NSData*)data contentType:(NSString*)type; 45 | 46 | @end 47 | 48 | @interface GCDWebServerDataResponse (Extensions) 49 | 50 | /** 51 | * Creates a data response from text encoded using UTF-8. 52 | */ 53 | + (instancetype)responseWithText:(NSString*)text; 54 | 55 | /** 56 | * Creates a data response from HTML encoded using UTF-8. 57 | */ 58 | + (instancetype)responseWithHTML:(NSString*)html; 59 | 60 | /** 61 | * Creates a data response from an HTML template encoded using UTF-8. 62 | * See -initWithHTMLTemplate:variables: for details. 63 | */ 64 | + (instancetype)responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables; 65 | 66 | /** 67 | * Creates a data response from a serialized JSON object and the default 68 | * "application/json" content type. 69 | */ 70 | + (instancetype)responseWithJSONObject:(id)object; 71 | 72 | /** 73 | * Creates a data response from a serialized JSON object and a custom 74 | * content type. 75 | */ 76 | + (instancetype)responseWithJSONObject:(id)object contentType:(NSString*)type; 77 | 78 | /** 79 | * Initializes a data response from text encoded using UTF-8. 80 | */ 81 | - (instancetype)initWithText:(NSString*)text; 82 | 83 | /** 84 | * Initializes a data response from HTML encoded using UTF-8. 85 | */ 86 | - (instancetype)initWithHTML:(NSString*)html; 87 | 88 | /** 89 | * Initializes a data response from an HTML template encoded using UTF-8. 90 | * 91 | * All occurences of "%variable%" within the HTML template are replaced with 92 | * their corresponding values. 93 | */ 94 | - (instancetype)initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables; 95 | 96 | /** 97 | * Initializes a data response from a serialized JSON object and the default 98 | * "application/json" content type. 99 | */ 100 | - (instancetype)initWithJSONObject:(id)object; 101 | 102 | /** 103 | * Initializes a data response from a serialized JSON object and a custom 104 | * content type. 105 | */ 106 | - (instancetype)initWithJSONObject:(id)object contentType:(NSString*)type; 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @interface GCDWebServerDataResponse () { 35 | @private 36 | NSData* _data; 37 | BOOL _done; 38 | } 39 | @end 40 | 41 | @implementation GCDWebServerDataResponse 42 | 43 | + (instancetype)responseWithData:(NSData*)data contentType:(NSString*)type { 44 | return [[[self class] alloc] initWithData:data contentType:type]; 45 | } 46 | 47 | - (instancetype)initWithData:(NSData*)data contentType:(NSString*)type { 48 | if (data == nil) { 49 | GWS_DNOT_REACHED(); 50 | return nil; 51 | } 52 | 53 | if ((self = [super init])) { 54 | _data = data; 55 | 56 | self.contentType = type; 57 | self.contentLength = data.length; 58 | } 59 | return self; 60 | } 61 | 62 | - (NSData*)readData:(NSError**)error { 63 | NSData* data; 64 | if (_done) { 65 | data = [NSData data]; 66 | } else { 67 | data = _data; 68 | _done = YES; 69 | } 70 | return data; 71 | } 72 | 73 | - (NSString*)description { 74 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 75 | [description appendString:@"\n\n"]; 76 | [description appendString:GCDWebServerDescribeData(_data, self.contentType)]; 77 | return description; 78 | } 79 | 80 | @end 81 | 82 | @implementation GCDWebServerDataResponse (Extensions) 83 | 84 | + (instancetype)responseWithText:(NSString*)text { 85 | return [[self alloc] initWithText:text]; 86 | } 87 | 88 | + (instancetype)responseWithHTML:(NSString*)html { 89 | return [[self alloc] initWithHTML:html]; 90 | } 91 | 92 | + (instancetype)responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables { 93 | return [[self alloc] initWithHTMLTemplate:path variables:variables]; 94 | } 95 | 96 | + (instancetype)responseWithJSONObject:(id)object { 97 | return [[self alloc] initWithJSONObject:object]; 98 | } 99 | 100 | + (instancetype)responseWithJSONObject:(id)object contentType:(NSString*)type { 101 | return [[self alloc] initWithJSONObject:object contentType:type]; 102 | } 103 | 104 | - (instancetype)initWithText:(NSString*)text { 105 | NSData* data = [text dataUsingEncoding:NSUTF8StringEncoding]; 106 | if (data == nil) { 107 | GWS_DNOT_REACHED(); 108 | return nil; 109 | } 110 | return [self initWithData:data contentType:@"text/plain; charset=utf-8"]; 111 | } 112 | 113 | - (instancetype)initWithHTML:(NSString*)html { 114 | NSData* data = [html dataUsingEncoding:NSUTF8StringEncoding]; 115 | if (data == nil) { 116 | GWS_DNOT_REACHED(); 117 | return nil; 118 | } 119 | return [self initWithData:data contentType:@"text/html; charset=utf-8"]; 120 | } 121 | 122 | - (instancetype)initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables { 123 | NSMutableString* html = [[NSMutableString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL]; 124 | [variables enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSString* value, BOOL* stop) { 125 | [html replaceOccurrencesOfString:[NSString stringWithFormat:@"%%%@%%", key] withString:value options:0 range:NSMakeRange(0, html.length)]; 126 | }]; 127 | id response = [self initWithHTML:html]; 128 | return response; 129 | } 130 | 131 | - (instancetype)initWithJSONObject:(id)object { 132 | return [self initWithJSONObject:object contentType:@"application/json"]; 133 | } 134 | 135 | - (instancetype)initWithJSONObject:(id)object contentType:(NSString*)type { 136 | NSData* data = [NSJSONSerialization dataWithJSONObject:object options:0 error:NULL]; 137 | if (data == nil) { 138 | return nil; 139 | } 140 | return [self initWithData:data contentType:type]; 141 | } 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerErrorResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerDataResponse.h" 29 | #import "GCDWebServerHTTPStatusCodes.h" 30 | 31 | /** 32 | * The GCDWebServerDataResponse subclass of GCDWebServerDataResponse generates 33 | * an HTML body from an HTTP status code and an error message. 34 | */ 35 | @interface GCDWebServerErrorResponse : GCDWebServerDataResponse 36 | 37 | /** 38 | * Creates a client error response with the corresponding HTTP status code. 39 | */ 40 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3); 41 | 42 | /** 43 | * Creates a server error response with the corresponding HTTP status code. 44 | */ 45 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3); 46 | 47 | /** 48 | * Creates a client error response with the corresponding HTTP status code 49 | * and an underlying NSError. 50 | */ 51 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4); 52 | 53 | /** 54 | * Creates a server error response with the corresponding HTTP status code 55 | * and an underlying NSError. 56 | */ 57 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4); 58 | 59 | /** 60 | * Initializes a client error response with the corresponding HTTP status code. 61 | */ 62 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3); 63 | 64 | /** 65 | * Initializes a server error response with the corresponding HTTP status code. 66 | */ 67 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3); 68 | 69 | /** 70 | * Initializes a client error response with the corresponding HTTP status code 71 | * and an underlying NSError. 72 | */ 73 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4); 74 | 75 | /** 76 | * Initializes a server error response with the corresponding HTTP status code 77 | * and an underlying NSError. 78 | */ 79 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4); 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerErrorResponse.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @interface GCDWebServerErrorResponse () 35 | - (instancetype)initWithStatusCode:(NSInteger)statusCode underlyingError:(NSError*)underlyingError messageFormat:(NSString*)format arguments:(va_list)arguments; 36 | @end 37 | 38 | @implementation GCDWebServerErrorResponse 39 | 40 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... { 41 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500)); 42 | va_list arguments; 43 | va_start(arguments, format); 44 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments]; 45 | va_end(arguments); 46 | return response; 47 | } 48 | 49 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... { 50 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600)); 51 | va_list arguments; 52 | va_start(arguments, format); 53 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments]; 54 | va_end(arguments); 55 | return response; 56 | } 57 | 58 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... { 59 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500)); 60 | va_list arguments; 61 | va_start(arguments, format); 62 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments]; 63 | va_end(arguments); 64 | return response; 65 | } 66 | 67 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... { 68 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600)); 69 | va_list arguments; 70 | va_start(arguments, format); 71 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments]; 72 | va_end(arguments); 73 | return response; 74 | } 75 | 76 | static inline NSString* _EscapeHTMLString(NSString* string) { 77 | return [string stringByReplacingOccurrencesOfString:@"\"" withString:@"""]; 78 | } 79 | 80 | - (instancetype)initWithStatusCode:(NSInteger)statusCode underlyingError:(NSError*)underlyingError messageFormat:(NSString*)format arguments:(va_list)arguments { 81 | NSString* message = [[NSString alloc] initWithFormat:format arguments:arguments]; 82 | NSString* title = [NSString stringWithFormat:@"HTTP Error %i", (int)statusCode]; 83 | NSString* error = underlyingError ? [NSString stringWithFormat:@"[%@] %@ (%li)", underlyingError.domain, _EscapeHTMLString(underlyingError.localizedDescription), (long)underlyingError.code] : @""; 84 | NSString* html = [NSString stringWithFormat:@"%@

%@: %@

%@

", 85 | title, title, _EscapeHTMLString(message), error]; 86 | if ((self = [self initWithHTML:html])) { 87 | self.statusCode = statusCode; 88 | } 89 | return self; 90 | } 91 | 92 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... { 93 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500)); 94 | va_list arguments; 95 | va_start(arguments, format); 96 | self = [self initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments]; 97 | va_end(arguments); 98 | return self; 99 | } 100 | 101 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... { 102 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600)); 103 | va_list arguments; 104 | va_start(arguments, format); 105 | self = [self initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments]; 106 | va_end(arguments); 107 | return self; 108 | } 109 | 110 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... { 111 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500)); 112 | va_list arguments; 113 | va_start(arguments, format); 114 | self = [self initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments]; 115 | va_end(arguments); 116 | return self; 117 | } 118 | 119 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... { 120 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600)); 121 | va_list arguments; 122 | va_start(arguments, format); 123 | self = [self initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments]; 124 | va_end(arguments); 125 | return self; 126 | } 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerFileResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerResponse.h" 29 | 30 | /** 31 | * The GCDWebServerFileResponse subclass of GCDWebServerResponse reads the body 32 | * of the HTTP response from a file on disk. 33 | * 34 | * It will automatically set the contentType, lastModifiedDate and eTag 35 | * properties of the GCDWebServerResponse according to the file extension and 36 | * metadata. 37 | */ 38 | @interface GCDWebServerFileResponse : GCDWebServerResponse 39 | 40 | /** 41 | * Creates a response with the contents of a file. 42 | */ 43 | + (instancetype)responseWithFile:(NSString*)path; 44 | 45 | /** 46 | * Creates a response like +responseWithFile: and sets the "Content-Disposition" 47 | * HTTP header for a download if the "attachment" argument is YES. 48 | */ 49 | + (instancetype)responseWithFile:(NSString*)path isAttachment:(BOOL)attachment; 50 | 51 | /** 52 | * Creates a response like +responseWithFile: but restricts the file contents 53 | * to a specific byte range. 54 | * 55 | * See -initWithFile:byteRange: for details. 56 | */ 57 | + (instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range; 58 | 59 | /** 60 | * Creates a response like +responseWithFile:byteRange: and sets the 61 | * "Content-Disposition" HTTP header for a download if the "attachment" 62 | * argument is YES. 63 | */ 64 | + (instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment; 65 | 66 | /** 67 | * Initializes a response with the contents of a file. 68 | */ 69 | - (instancetype)initWithFile:(NSString*)path; 70 | 71 | /** 72 | * Initializes a response like +responseWithFile: and sets the 73 | * "Content-Disposition" HTTP header for a download if the "attachment" 74 | * argument is YES. 75 | */ 76 | - (instancetype)initWithFile:(NSString*)path isAttachment:(BOOL)attachment; 77 | 78 | /** 79 | * Initializes a response like -initWithFile: but restricts the file contents 80 | * to a specific byte range. This range should be set to (NSUIntegerMax, 0) for 81 | * the full file, (offset, length) if expressed from the beginning of the file, 82 | * or (NSUIntegerMax, length) if expressed from the end of the file. The "offset" 83 | * and "length" values will be automatically adjusted to be compatible with the 84 | * actual size of the file. 85 | * 86 | * This argument would typically be set to the value of the byteRange property 87 | * of the current GCDWebServerRequest. 88 | */ 89 | - (instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range; 90 | 91 | /** 92 | * This method is the designated initializer for the class. 93 | */ 94 | - (instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment; 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerFileResponse.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import 33 | 34 | #import "GCDWebServerPrivate.h" 35 | 36 | #define kFileReadBufferSize (32 * 1024) 37 | 38 | @interface GCDWebServerFileResponse () { 39 | @private 40 | NSString* _path; 41 | NSUInteger _offset; 42 | NSUInteger _size; 43 | int _file; 44 | } 45 | @end 46 | 47 | @implementation GCDWebServerFileResponse 48 | 49 | + (instancetype)responseWithFile:(NSString*)path { 50 | return [[[self class] alloc] initWithFile:path]; 51 | } 52 | 53 | + (instancetype)responseWithFile:(NSString*)path isAttachment:(BOOL)attachment { 54 | return [[[self class] alloc] initWithFile:path isAttachment:attachment]; 55 | } 56 | 57 | + (instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range { 58 | return [[[self class] alloc] initWithFile:path byteRange:range]; 59 | } 60 | 61 | + (instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment { 62 | return [[[self class] alloc] initWithFile:path byteRange:range isAttachment:attachment]; 63 | } 64 | 65 | - (instancetype)initWithFile:(NSString*)path { 66 | return [self initWithFile:path byteRange:NSMakeRange(NSUIntegerMax, 0) isAttachment:NO]; 67 | } 68 | 69 | - (instancetype)initWithFile:(NSString*)path isAttachment:(BOOL)attachment { 70 | return [self initWithFile:path byteRange:NSMakeRange(NSUIntegerMax, 0) isAttachment:attachment]; 71 | } 72 | 73 | - (instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range { 74 | return [self initWithFile:path byteRange:range isAttachment:NO]; 75 | } 76 | 77 | static inline NSDate* _NSDateFromTimeSpec(const struct timespec* t) { 78 | return [NSDate dateWithTimeIntervalSince1970:((NSTimeInterval)t->tv_sec + (NSTimeInterval)t->tv_nsec / 1000000000.0)]; 79 | } 80 | 81 | - (instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment { 82 | struct stat info; 83 | if (lstat([path fileSystemRepresentation], &info) || !(info.st_mode & S_IFREG)) { 84 | GWS_DNOT_REACHED(); 85 | return nil; 86 | } 87 | #ifndef __LP64__ 88 | if (info.st_size >= (off_t)4294967295) { // In 32 bit mode, we can't handle files greater than 4 GiBs (don't use "NSUIntegerMax" here to avoid potential unsigned to signed conversion issues) 89 | GWS_DNOT_REACHED(); 90 | return nil; 91 | } 92 | #endif 93 | NSUInteger fileSize = (NSUInteger)info.st_size; 94 | 95 | BOOL hasByteRange = GCDWebServerIsValidByteRange(range); 96 | if (hasByteRange) { 97 | if (range.location != NSUIntegerMax) { 98 | range.location = MIN(range.location, fileSize); 99 | range.length = MIN(range.length, fileSize - range.location); 100 | } else { 101 | range.length = MIN(range.length, fileSize); 102 | range.location = fileSize - range.length; 103 | } 104 | if (range.length == 0) { 105 | return nil; // TODO: Return 416 status code and "Content-Range: bytes */{file length}" header 106 | } 107 | } else { 108 | range.location = 0; 109 | range.length = fileSize; 110 | } 111 | 112 | if ((self = [super init])) { 113 | _path = [path copy]; 114 | _offset = range.location; 115 | _size = range.length; 116 | if (hasByteRange) { 117 | [self setStatusCode:kGCDWebServerHTTPStatusCode_PartialContent]; 118 | [self setValue:[NSString stringWithFormat:@"bytes %lu-%lu/%lu", (unsigned long)_offset, (unsigned long)(_offset + _size - 1), (unsigned long)fileSize] forAdditionalHeader:@"Content-Range"]; 119 | GWS_LOG_DEBUG(@"Using content bytes range [%lu-%lu] for file \"%@\"", (unsigned long)_offset, (unsigned long)(_offset + _size - 1), path); 120 | } 121 | 122 | if (attachment) { 123 | NSString* fileName = [path lastPathComponent]; 124 | NSData* data = [[fileName stringByReplacingOccurrencesOfString:@"\"" withString:@""] dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:YES]; 125 | NSString* lossyFileName = data ? [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding] : nil; 126 | if (lossyFileName) { 127 | NSString* value = [NSString stringWithFormat:@"attachment; filename=\"%@\"; filename*=UTF-8''%@", lossyFileName, GCDWebServerEscapeURLString(fileName)]; 128 | [self setValue:value forAdditionalHeader:@"Content-Disposition"]; 129 | } else { 130 | GWS_DNOT_REACHED(); 131 | } 132 | } 133 | 134 | self.contentType = GCDWebServerGetMimeTypeForExtension([_path pathExtension]); 135 | self.contentLength = _size; 136 | self.lastModifiedDate = _NSDateFromTimeSpec(&info.st_mtimespec); 137 | self.eTag = [NSString stringWithFormat:@"%llu/%li/%li", info.st_ino, info.st_mtimespec.tv_sec, info.st_mtimespec.tv_nsec]; 138 | } 139 | return self; 140 | } 141 | 142 | - (BOOL)open:(NSError**)error { 143 | _file = open([_path fileSystemRepresentation], O_NOFOLLOW | O_RDONLY); 144 | if (_file <= 0) { 145 | if (error) { 146 | *error = GCDWebServerMakePosixError(errno); 147 | } 148 | return NO; 149 | } 150 | if (lseek(_file, _offset, SEEK_SET) != (off_t)_offset) { 151 | if (error) { 152 | *error = GCDWebServerMakePosixError(errno); 153 | } 154 | close(_file); 155 | return NO; 156 | } 157 | return YES; 158 | } 159 | 160 | - (NSData*)readData:(NSError**)error { 161 | size_t length = MIN((NSUInteger)kFileReadBufferSize, _size); 162 | NSMutableData* data = [[NSMutableData alloc] initWithLength:length]; 163 | ssize_t result = read(_file, data.mutableBytes, length); 164 | if (result < 0) { 165 | if (error) { 166 | *error = GCDWebServerMakePosixError(errno); 167 | } 168 | return nil; 169 | } 170 | if (result > 0) { 171 | [data setLength:result]; 172 | _size -= result; 173 | } 174 | return data; 175 | } 176 | 177 | - (void)close { 178 | close(_file); 179 | } 180 | 181 | - (NSString*)description { 182 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 183 | [description appendFormat:@"\n\n{%@}", _path]; 184 | return description; 185 | } 186 | 187 | @end 188 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServerResponse.h" 29 | 30 | /** 31 | * The GCDWebServerStreamBlock is called to stream the data for the HTTP body. 32 | * The block must return either a chunk of data, an empty NSData when done, or 33 | * nil on error and set the "error" argument which is guaranteed to be non-NULL. 34 | */ 35 | typedef NSData* (^GCDWebServerStreamBlock)(NSError** error); 36 | 37 | /** 38 | * The GCDWebServerAsyncStreamBlock works like the GCDWebServerStreamBlock 39 | * except the streamed data can be returned at a later time allowing for 40 | * truly asynchronous generation of the data. 41 | * 42 | * The block must call "completionBlock" passing the new chunk of data when ready, 43 | * an empty NSData when done, or nil on error and pass a NSError. 44 | * 45 | * The block cannot call "completionBlock" more than once per invocation. 46 | */ 47 | typedef void (^GCDWebServerAsyncStreamBlock)(GCDWebServerBodyReaderCompletionBlock completionBlock); 48 | 49 | /** 50 | * The GCDWebServerStreamedResponse subclass of GCDWebServerResponse streams 51 | * the body of the HTTP response using a GCD block. 52 | */ 53 | @interface GCDWebServerStreamedResponse : GCDWebServerResponse 54 | 55 | /** 56 | * Creates a response with streamed data and a given content type. 57 | */ 58 | + (instancetype)responseWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block; 59 | 60 | /** 61 | * Creates a response with async streamed data and a given content type. 62 | */ 63 | + (instancetype)responseWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block; 64 | 65 | /** 66 | * Initializes a response with streamed data and a given content type. 67 | */ 68 | - (instancetype)initWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block; 69 | 70 | /** 71 | * This method is the designated initializer for the class. 72 | */ 73 | - (instancetype)initWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #if !__has_feature(objc_arc) 29 | #error GCDWebServer requires ARC 30 | #endif 31 | 32 | #import "GCDWebServerPrivate.h" 33 | 34 | @interface GCDWebServerStreamedResponse () { 35 | @private 36 | GCDWebServerAsyncStreamBlock _block; 37 | } 38 | @end 39 | 40 | @implementation GCDWebServerStreamedResponse 41 | 42 | + (instancetype)responseWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block { 43 | return [[[self class] alloc] initWithContentType:type streamBlock:block]; 44 | } 45 | 46 | + (instancetype)responseWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block { 47 | return [[[self class] alloc] initWithContentType:type asyncStreamBlock:block]; 48 | } 49 | 50 | - (instancetype)initWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block { 51 | return [self initWithContentType:type asyncStreamBlock:^(GCDWebServerBodyReaderCompletionBlock completionBlock) { 52 | 53 | NSError* error = nil; 54 | NSData* data = block(&error); 55 | completionBlock(data, error); 56 | 57 | }]; 58 | } 59 | 60 | - (instancetype)initWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block { 61 | if ((self = [super init])) { 62 | _block = [block copy]; 63 | 64 | self.contentType = type; 65 | } 66 | return self; 67 | } 68 | 69 | - (void)asyncReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block { 70 | _block(block); 71 | } 72 | 73 | - (NSString*)description { 74 | NSMutableString* description = [NSMutableString stringWithString:[super description]]; 75 | [description appendString:@"\n\n"]; 76 | return description; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/Info.plist -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/css/index.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | .row-file { 29 | height: 40px; 30 | } 31 | 32 | .column-icon { 33 | width: 40px; 34 | text-align: center; 35 | } 36 | 37 | .column-name { 38 | } 39 | 40 | .column-size { 41 | width: 100px; 42 | text-align: right; 43 | } 44 | 45 | .column-move { 46 | width: 40px; 47 | text-align: center; 48 | } 49 | 50 | .column-delete { 51 | width: 40px; 52 | text-align: center; 53 | } 54 | 55 | .column-path { 56 | } 57 | 58 | .column-progress { 59 | width: 200px; 60 | } 61 | 62 | .footer { 63 | color: #999; 64 | text-align: center; 65 | font-size: 0.9em; 66 | } 67 | 68 | #reload { 69 | float: right; 70 | } 71 | 72 | #create-input { 73 | width: 50%; 74 | height: 20px; 75 | } 76 | 77 | #move-input { 78 | width: 80%; 79 | height: 20px; 80 | } 81 | 82 | /* Bootstrap overrides */ 83 | 84 | .btn:focus { 85 | outline: none; /* FIXME: Work around for Chrome only but still draws focus ring while button pressed */ 86 | } 87 | 88 | .btn-toolbar { 89 | margin-top: 30px; 90 | margin-bottom: 20px; 91 | } 92 | 93 | .table .progress { 94 | margin-top: 0px; 95 | margin-bottom: 0px; 96 | height: 16px; 97 | } 98 | 99 | .panel-default > .panel-heading { 100 | color: #555; 101 | } 102 | 103 | .breadcrumb { 104 | background-color: transparent; 105 | border-radius: 0px; 106 | margin-bottom: 0px; 107 | padding: 0px; 108 | } 109 | 110 | .breadcrumb > .active { 111 | color: #555; 112 | } 113 | 114 | .breadcrumb > li + li:before { 115 | color: #999; 116 | } 117 | 118 | .table > tbody > tr > td { 119 | vertical-align: middle; 120 | } 121 | 122 | .table > tbody > tr > td > p { 123 | margin: 0px; 124 | } 125 | 126 | /* Initial state */ 127 | 128 | .uploading { 129 | display: none; 130 | } 131 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/css/jquery.fileupload.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | /* 3 | * jQuery File Upload Plugin CSS 1.3.0 4 | * https://github.com/blueimp/jQuery-File-Upload 5 | * 6 | * Copyright 2013, Sebastian Tschan 7 | * https://blueimp.net 8 | * 9 | * Licensed under the MIT license: 10 | * http://www.opensource.org/licenses/MIT 11 | */ 12 | 13 | .fileinput-button { 14 | position: relative; 15 | overflow: hidden; 16 | } 17 | .fileinput-button input { 18 | position: absolute; 19 | top: 0; 20 | right: 0; 21 | margin: 0; 22 | opacity: 0; 23 | -ms-filter: 'alpha(opacity=0)'; 24 | font-size: 200px; 25 | direction: ltr; 26 | cursor: pointer; 27 | } 28 | 29 | /* Fixes for IE < 8 */ 30 | @media screen\9 { 31 | .fileinput-button input { 32 | filter: alpha(opacity=0); 33 | font-size: 100%; 34 | height: 100%; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "PROLOGUE" = "

Drag & drop files on this window or use the \"Upload Files…\" button to upload new files.

"; 2 | "EPILOGUE" = ""; 3 | "FOOTER_FORMAT" = "%@ %@"; 4 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/index.html: -------------------------------------------------------------------------------- 1 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | %title% 35 | 36 | 37 | 38 | 39 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 | 55 | 56 | 57 |
58 | 59 | 62 | 63 | %prologue% 64 | 65 |
66 | 67 |
68 | 72 | 75 | 78 |
79 | 80 |
81 |
File Uploads in Progress
82 |
83 |
84 | 85 |
86 |
87 | 88 |
89 |
90 |
91 | 92 | %epilogue% 93 | 94 | 95 | 96 |
97 | 98 | 118 | 119 | 139 | 140 | 171 | 172 | 187 | 188 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); 5 | a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; 6 | c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| 7 | "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f); 8 | if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d #mq-test-1 { width: 42px; }',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b&"'\x00]/g,b.encMap={"<":"<",">":">","&":"&",'"':""","'":"'"},b.encode=function(a){return(null==a?"":""+a).replace(b.encReg,function(a){return b.encMap[a]||""})},b.arg="o",b.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return b}):a.tmpl=b}(this); -------------------------------------------------------------------------------- /Pods/GCDWebServer/GCDWebUploader/GCDWebUploader.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2015, Pierre-Olivier Latour 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Pierre-Olivier Latour may not be used to endorse 13 | or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import "GCDWebServer.h" 29 | 30 | @class GCDWebUploader; 31 | 32 | /** 33 | * Delegate methods for GCDWebUploader. 34 | * 35 | * @warning These methods are always called on the main thread in a serialized way. 36 | */ 37 | @protocol GCDWebUploaderDelegate 38 | @optional 39 | 40 | /** 41 | * This method is called whenever a file has been downloaded. 42 | */ 43 | - (void)webUploader:(GCDWebUploader*)uploader didDownloadFileAtPath:(NSString*)path; 44 | 45 | /** 46 | * This method is called whenever a file has been uploaded. 47 | */ 48 | - (void)webUploader:(GCDWebUploader*)uploader didUploadFileAtPath:(NSString*)path; 49 | 50 | /** 51 | * This method is called whenever a file or directory has been moved. 52 | */ 53 | - (void)webUploader:(GCDWebUploader*)uploader didMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath; 54 | 55 | /** 56 | * This method is called whenever a file or directory has been deleted. 57 | */ 58 | - (void)webUploader:(GCDWebUploader*)uploader didDeleteItemAtPath:(NSString*)path; 59 | 60 | /** 61 | * This method is called whenever a directory has been created. 62 | */ 63 | - (void)webUploader:(GCDWebUploader*)uploader didCreateDirectoryAtPath:(NSString*)path; 64 | 65 | @end 66 | 67 | /** 68 | * The GCDWebUploader subclass of GCDWebServer implements an HTML 5 web browser 69 | * interface for uploading or downloading files, and moving or deleting files 70 | * or directories. 71 | * 72 | * See the README.md file for more information about the features of GCDWebUploader. 73 | * 74 | * @warning For GCDWebUploader to work, "GCDWebUploader.bundle" must be added 75 | * to the resources of the Xcode target. 76 | */ 77 | @interface GCDWebUploader : GCDWebServer 78 | 79 | /** 80 | * Returns the upload directory as specified when the uploader was initialized. 81 | */ 82 | @property(nonatomic, readonly) NSString* uploadDirectory; 83 | 84 | /** 85 | * Sets the delegate for the uploader. 86 | */ 87 | @property(nonatomic, assign) id delegate; 88 | 89 | /** 90 | * Sets which files are allowed to be operated on depending on their extension. 91 | * 92 | * The default value is nil i.e. all file extensions are allowed. 93 | */ 94 | @property(nonatomic, copy) NSArray* allowedFileExtensions; 95 | 96 | /** 97 | * Sets if files and directories whose name start with a period are allowed to 98 | * be operated on. 99 | * 100 | * The default value is NO. 101 | */ 102 | @property(nonatomic) BOOL allowHiddenItems; 103 | 104 | /** 105 | * Sets the title for the uploader web interface. 106 | * 107 | * The default value is the application name. 108 | * 109 | * @warning Any reserved HTML characters in the string value for this property 110 | * must have been replaced by character entities e.g. "&" becomes "&". 111 | */ 112 | @property(nonatomic, copy) NSString* title; 113 | 114 | /** 115 | * Sets the header for the uploader web interface. 116 | * 117 | * The default value is the same as the title property. 118 | * 119 | * @warning Any reserved HTML characters in the string value for this property 120 | * must have been replaced by character entities e.g. "&" becomes "&". 121 | */ 122 | @property(nonatomic, copy) NSString* header; 123 | 124 | /** 125 | * Sets the prologue for the uploader web interface. 126 | * 127 | * The default value is a short help text. 128 | * 129 | * @warning The string value for this property must be raw HTML 130 | * e.g. "

Some text

" 131 | */ 132 | @property(nonatomic, copy) NSString* prologue; 133 | 134 | /** 135 | * Sets the epilogue for the uploader web interface. 136 | * 137 | * The default value is nil i.e. no epilogue. 138 | * 139 | * @warning The string value for this property must be raw HTML 140 | * e.g. "

Some text

" 141 | */ 142 | @property(nonatomic, copy) NSString* epilogue; 143 | 144 | /** 145 | * Sets the footer for the uploader web interface. 146 | * 147 | * The default value is the application name and version. 148 | * 149 | * @warning Any reserved HTML characters in the string value for this property 150 | * must have been replaced by character entities e.g. "&" becomes "&". 151 | */ 152 | @property(nonatomic, copy) NSString* footer; 153 | 154 | /** 155 | * This method is the designated initializer for the class. 156 | */ 157 | - (instancetype)initWithUploadDirectory:(NSString*)path; 158 | 159 | @end 160 | 161 | /** 162 | * Hooks to customize the behavior of GCDWebUploader. 163 | * 164 | * @warning These methods can be called on any GCD thread. 165 | */ 166 | @interface GCDWebUploader (Subclassing) 167 | 168 | /** 169 | * This method is called to check if a file upload is allowed to complete. 170 | * The uploaded file is available for inspection at "tempPath". 171 | * 172 | * The default implementation returns YES. 173 | */ 174 | - (BOOL)shouldUploadFileAtPath:(NSString*)path withTemporaryFile:(NSString*)tempPath; 175 | 176 | /** 177 | * This method is called to check if a file or directory is allowed to be moved. 178 | * 179 | * The default implementation returns YES. 180 | */ 181 | - (BOOL)shouldMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath; 182 | 183 | /** 184 | * This method is called to check if a file or directory is allowed to be deleted. 185 | * 186 | * The default implementation returns YES. 187 | */ 188 | - (BOOL)shouldDeleteItemAtPath:(NSString*)path; 189 | 190 | /** 191 | * This method is called to check if a directory is allowed to be created. 192 | * 193 | * The default implementation returns YES. 194 | */ 195 | - (BOOL)shouldCreateDirectoryAtPath:(NSString*)path; 196 | 197 | @end 198 | -------------------------------------------------------------------------------- /Pods/GCDWebServer/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2014, Pierre-Olivier Latour 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * The name of Pierre-Olivier Latour may not be used to endorse 12 | or promote products derived from this software without specific 13 | prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /Pods/Headers/Private/ARWebServerActivity/ARWebServerActivity.h: -------------------------------------------------------------------------------- 1 | ../../../../ARWebServerActivity/ARWebServerActivity.h -------------------------------------------------------------------------------- /Pods/Headers/Private/ARWebServerActivity/ARWebServerActivityViewController.h: -------------------------------------------------------------------------------- 1 | ../../../../ARWebServerActivity/ARWebServerActivityViewController.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServer.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServer.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerConnection.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerConnection.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerDataRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerDataRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerDataResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerErrorResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerErrorResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerFileRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerFileResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerFileResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerFunctions.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerFunctions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerHTTPStatusCodes.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerMultiPartFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerPrivate.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerPrivate.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerStreamedResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebServerURLEncodedFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Private/GCDWebServer/GCDWebUploader.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebUploader/GCDWebUploader.h -------------------------------------------------------------------------------- /Pods/Headers/Public/ARWebServerActivity/ARWebServerActivity.h: -------------------------------------------------------------------------------- 1 | ../../../../ARWebServerActivity/ARWebServerActivity.h -------------------------------------------------------------------------------- /Pods/Headers/Public/ARWebServerActivity/ARWebServerActivityViewController.h: -------------------------------------------------------------------------------- 1 | ../../../../ARWebServerActivity/ARWebServerActivityViewController.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServer.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServer.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerConnection.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerConnection.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerDataRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerDataRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerDataResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerDataResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerErrorResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerErrorResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerFileRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerFileRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerFileResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerFileResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerFunctions.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerFunctions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerHTTPStatusCodes.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerMultiPartFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Core/GCDWebServerResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerStreamedResponse.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Responses/GCDWebServerStreamedResponse.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebServerURLEncodedFormRequest.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebServer/Requests/GCDWebServerURLEncodedFormRequest.h -------------------------------------------------------------------------------- /Pods/Headers/Public/GCDWebServer/GCDWebUploader.h: -------------------------------------------------------------------------------- 1 | ../../../GCDWebServer/GCDWebUploader/GCDWebUploader.h -------------------------------------------------------------------------------- /Pods/Local Podspecs/ARWebServerActivity.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ARWebServerActivity", 3 | "version": "1.0.1", 4 | "license": "MIT", 5 | "summary": "A UIActivity subclass that share files via GCDWebServer with Twitter Bootstrap UI.", 6 | "homepage": "https://github.com/alexruperez/ARWebServerActivity", 7 | "screenshots": "https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/master/screenshot.png", 8 | "authors": { 9 | "Alex Rupérez": "contact@alexruperez.com" 10 | }, 11 | "social_media_url": "http://twitter.com/alexruperez", 12 | "platforms": { 13 | "ios": "6.0" 14 | }, 15 | "source": { 16 | "git": "https://github.com/alexruperez/ARWebServerActivity.git", 17 | "tag": "1.0.1" 18 | }, 19 | "source_files": "ARWebServerActivity/*.{h,m,swift}", 20 | "resources": "ARWebServerActivity/ARWebServerActivity.bundle", 21 | "requires_arc": true, 22 | "frameworks": [ 23 | "UIKit", 24 | "CoreGraphics" 25 | ], 26 | "dependencies": { 27 | "GCDWebServer/WebUploader": [ 28 | "~> 3.3" 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ARWebServerActivity (1.0.1): 3 | - GCDWebServer/WebUploader (~> 3.3) 4 | - GCDWebServer/Core (3.3.2) 5 | - GCDWebServer/WebUploader (3.3.2): 6 | - GCDWebServer/WebUploader/Core (= 3.3.2) 7 | - GCDWebServer/WebUploader/Core (3.3.2): 8 | - GCDWebServer/Core 9 | 10 | DEPENDENCIES: 11 | - ARWebServerActivity (from `./`) 12 | 13 | EXTERNAL SOURCES: 14 | ARWebServerActivity: 15 | :path: "./" 16 | 17 | SPEC CHECKSUMS: 18 | ARWebServerActivity: 11da4907792fbea0b67eec5339d4848852dbbf41 19 | GCDWebServer: 2a375ec42839a41d7187d04e5b688d32fa5c4cd5 20 | 21 | COCOAPODS: 0.39.0 22 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcshareddata/xcschemes/ARWebServerActivity.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/Target Support Files/ARWebServerActivity/ARWebServerActivity-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_ARWebServerActivity : NSObject 3 | @end 4 | @implementation PodsDummy_ARWebServerActivity 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/ARWebServerActivity/ARWebServerActivity-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/ARWebServerActivity/ARWebServerActivity.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/ARWebServerActivity" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/ARWebServerActivity" "${PODS_ROOT}/Headers/Public/GCDWebServer" 3 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "UIKit" 4 | PODS_ROOT = ${SRCROOT} 5 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_GCDWebServer : NSObject 3 | @end 4 | @implementation PodsDummy_GCDWebServer 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/GCDWebServer/GCDWebServer.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/GCDWebServer" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/ARWebServerActivity" "${PODS_ROOT}/Headers/Public/GCDWebServer" 3 | OTHER_LDFLAGS = -l"z" -framework "CFNetwork" -framework "MobileCoreServices" 4 | PODS_ROOT = ${SRCROOT} 5 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## ARWebServerActivity 5 | 6 | 7 | The MIT License (MIT) 8 | 9 | Copyright (c) 2013 alexruperez 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in 19 | all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | 29 | 30 | ## GCDWebServer 31 | 32 | Copyright (c) 2012-2014, Pierre-Olivier Latour 33 | All rights reserved. 34 | 35 | Redistribution and use in source and binary forms, with or without 36 | modification, are permitted provided that the following conditions are met: 37 | * Redistributions of source code must retain the above copyright 38 | notice, this list of conditions and the following disclaimer. 39 | * Redistributions in binary form must reproduce the above copyright 40 | notice, this list of conditions and the following disclaimer in the 41 | documentation and/or other materials provided with the distribution. 42 | * The name of Pierre-Olivier Latour may not be used to endorse 43 | or promote products derived from this software without specific 44 | prior written permission. 45 | 46 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 47 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 49 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 50 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 51 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 52 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 53 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 54 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 55 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 | 57 | Generated by CocoaPods - http://cocoapods.org 58 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | 18 | The MIT License (MIT) 19 | 20 | Copyright (c) 2013 alexruperez 21 | 22 | Permission is hereby granted, free of charge, to any person obtaining a copy 23 | of this software and associated documentation files (the "Software"), to deal 24 | in the Software without restriction, including without limitation the rights 25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 26 | copies of the Software, and to permit persons to whom the Software is 27 | furnished to do so, subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in 30 | all copies or substantial portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 38 | THE SOFTWARE. 39 | 40 | Title 41 | ARWebServerActivity 42 | Type 43 | PSGroupSpecifier 44 | 45 | 46 | FooterText 47 | Copyright (c) 2012-2014, Pierre-Olivier Latour 48 | All rights reserved. 49 | 50 | Redistribution and use in source and binary forms, with or without 51 | modification, are permitted provided that the following conditions are met: 52 | * Redistributions of source code must retain the above copyright 53 | notice, this list of conditions and the following disclaimer. 54 | * Redistributions in binary form must reproduce the above copyright 55 | notice, this list of conditions and the following disclaimer in the 56 | documentation and/or other materials provided with the distribution. 57 | * The name of Pierre-Olivier Latour may not be used to endorse 58 | or promote products derived from this software without specific 59 | prior written permission. 60 | 61 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 62 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 63 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 64 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY 65 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 66 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 67 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 68 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 69 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 70 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 71 | 72 | Title 73 | GCDWebServer 74 | Type 75 | PSGroupSpecifier 76 | 77 | 78 | FooterText 79 | Generated by CocoaPods - http://cocoapods.org 80 | Title 81 | 82 | Type 83 | PSGroupSpecifier 84 | 85 | 86 | StringsTable 87 | Acknowledgements 88 | Title 89 | Acknowledgements 90 | 91 | 92 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods : NSObject 3 | @end 4 | @implementation PodsDummy_Pods 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY="$(cd "${1%/*}" && pwd)" 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | if [[ "$CONFIGURATION" == "Debug" ]]; then 61 | install_resource "../ARWebServerActivity/ARWebServerActivity.bundle" 62 | install_resource "GCDWebServer/GCDWebUploader/GCDWebUploader.bundle" 63 | fi 64 | if [[ "$CONFIGURATION" == "Release" ]]; then 65 | install_resource "../ARWebServerActivity/ARWebServerActivity.bundle" 66 | install_resource "GCDWebServer/GCDWebUploader/GCDWebUploader.bundle" 67 | fi 68 | 69 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 70 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 71 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 72 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 73 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 74 | fi 75 | rm -f "$RESOURCES_TO_COPY" 76 | 77 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 78 | then 79 | case "${TARGETED_DEVICE_FAMILY}" in 80 | 1,2) 81 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 82 | ;; 83 | 1) 84 | TARGET_DEVICE_ARGS="--target-device iphone" 85 | ;; 86 | 2) 87 | TARGET_DEVICE_ARGS="--target-device ipad" 88 | ;; 89 | *) 90 | TARGET_DEVICE_ARGS="--target-device mac" 91 | ;; 92 | esac 93 | 94 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 95 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 96 | while read line; do 97 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 98 | XCASSET_FILES+=("$line") 99 | fi 100 | done <<<"$OTHER_XCASSETS" 101 | 102 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 103 | fi 104 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/ARWebServerActivity" "${PODS_ROOT}/Headers/Public/GCDWebServer" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/ARWebServerActivity" -isystem "${PODS_ROOT}/Headers/Public/GCDWebServer" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"ARWebServerActivity" -l"GCDWebServer" -l"z" -framework "CFNetwork" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "UIKit" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/ARWebServerActivity" "${PODS_ROOT}/Headers/Public/GCDWebServer" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/ARWebServerActivity" -isystem "${PODS_ROOT}/Headers/Public/GCDWebServer" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"ARWebServerActivity" -l"GCDWebServer" -l"z" -framework "CFNetwork" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "UIKit" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ARWebServerActivity 2 | 3 | [![Twitter](http://img.shields.io/badge/contact-@alexruperez-blue.svg?style=flat)](http://twitter.com/alexruperez) 4 | [![Version](https://img.shields.io/cocoapods/v/ARWebServerActivity.svg?style=flat)](http://cocoadocs.org/docsets/ARWebServerActivity) 5 | [![License](https://img.shields.io/cocoapods/l/ARWebServerActivity.svg?style=flat)](http://cocoadocs.org/docsets/ARWebServerActivity) 6 | [![Platform](https://img.shields.io/cocoapods/p/ARWebServerActivity.svg?style=flat)](http://cocoadocs.org/docsets/ARWebServerActivity) 7 | [![Analytics](https://ga-beacon.appspot.com/UA-55329295-1/ARWebServerActivity/readme?pixel)](https://github.com/igrigorik/ga-beacon) 8 | 9 | ## Overview 10 | 11 | `ARWebServerActivity` is a `UIActivity` subclass that provides an "Share via web server" action to a `UIActivityViewController` to share files via [swisspol/GCDWebServer](https://github.com/swisspol/GCDWebServer) with Twitter Bootstrap UI. 12 | 13 | You can share: 14 | - NSString as TXT File. 15 | - UIImage as PNG File. 16 | - NSURL to a local/remote file. 17 | - NSData as DATA File. 18 | - NSDictionary as JSON File. 19 | - NSArray as JSON File. 20 | 21 | ![ARWebServerActivity screenshot](https://raw.github.com/alexruperez/ARWebServerActivity/master/screenshot.png "ARWebServerActivity screenshot") 22 | 23 | ## Clone the example proyect 24 | 25 | To pull the [swisspol/GCDWebServer](https://github.com/swisspol/GCDWebServer) submodule run: 26 | 27 | `git clone --recursive git@github.com:alexruperez/ARWebServerActivity.git` 28 | 29 | ## Requirements 30 | 31 | - As `UIActivity` is iOS >= 6 only, so is the subclass. 32 | - This project uses ARC. If you want to use it in a non ARC project, you must add the `-fobjc-arc` compiler flag to ARWebServerActivity.m and ARWebServerActivityViewController.m in Target Settings > Build Phases > Compile Sources. 33 | 34 | ## Installation 35 | 36 | Add the `ARWebServerActivity` subfolder to your project. There are no required libraries other than [swisspol/GCDWebServer](https://github.com/swisspol/GCDWebServer) and its requirements. 37 | 38 | ## Usage 39 | 40 | *(See example Xcode project)* 41 | 42 | Simply `alloc`/`init` an instance of `ARWebServerActivity` and pass that object into the applicationActivities array when creating a `UIActivityViewController`. 43 | 44 | ```objectivec 45 | ARWebServerActivity *webServerActivity = [[ARWebServerActivity alloc] init]; 46 | UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Hello World!", [UIImage imageNamed:@"Example"], [NSURL fileURLWithPath:@"file/path"], [NSURL URLWithString:@"file/url"], [@"data" dataUsingEncoding:NSUTF8StringEncoding], @{@"key": @[@"value1", @"value2"]}, @[@"value1", @"value2"]] applicationActivities:@[webServerActivity]]; 47 | [self presentViewController:activityViewController animated:YES completion:nil]; 48 | ``` 49 | 50 | Note that you can include the activity in any UIActivityViewController and it will only be shown to the user if there is a valid object in the activity items. 51 | 52 | ## Customization 53 | 54 | To customize this control you can use: 55 | 56 | ```objectivec 57 | - (instancetype)initWithPort:(NSNumber *)port bonjourName:(NSString *)bonjourName path:(NSString *)path activityViewController:(UIViewController *)activityViewController; 58 | ``` 59 | 60 | - `port`: [swisspol/GCDWebServer](https://github.com/swisspol/GCDWebServer) port. 61 | - `bonjourName`: If you want your server be visible at Bonjour. 62 | - `path`: If you want to change the local files path shared by your server. Note that will be removed after sharing. 63 | - `activityViewController`: If you want to change the default control UI, you can subclass `ARWebServerActivityViewController` and not call `[super viewWillAppear:animated];`, make your own UIViewController or improve my `ARWebServerActivityViewController` and make a pull request. 64 | 65 | ## TO-DO (Help needed!) 66 | 67 | - Add (programmatically) Auto Layout constraints to `ARWebServerActivityViewController` and example Xcode project for screen rotation. 68 | - Improve `ARWebServerActivityViewController` UI. 69 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexruperez/ARWebServerActivity/fde3382a6e81d8b4b5f5d2d66c1edf3ecb01ecb1/screenshot.png --------------------------------------------------------------------------------