Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended Bonjour publishing to support more than one type. #109

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github "CocoaLumberjack/CocoaLumberjack" ~> 2.1.0
github "robbiehanson/CocoaAsyncSocket" "master"
2 changes: 2 additions & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github "robbiehanson/CocoaAsyncSocket" "fe716222f72811e66de02809eae8db77dacb6a83"
github "CocoaLumberjack/CocoaLumberjack" "7707947dd98a9cb235881643aaf71fab99c4b972"
44 changes: 44 additions & 0 deletions CocoaHTTPServer.podspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "CocoaHTTPServer",
"version": "2.3",
"license": "BSD",
"summary": "A small, lightweight, embeddable HTTP server for Mac OS X or iOS applications.",
"homepage": "https://github.com/robbiehanson/CocoaHTTPServer",
"authors": {
"Robbie Hanson": "[email protected]"
},
"source": {
"git": "https://github.com/robbiehanson/CocoaHTTPServer.git",
"tag": "2.3"
},
"source_files": "Sources/CocoaHTTPServer/{Core,Extensions}/**/*.{h,m}",
"requires_arc": true,
"platforms": {
"ios": "5.0",
"osx": "10.7"
},
"ios": {
"frameworks": [
"CFNetwork",
"Security"
]
},
"osx": {
"frameworks": [
"CoreServices",
"Security"
]
},
"libraries": "xml2",
"xcconfig": {
"HEADER_SEARCH_PATHS": "\"$(SDKROOT)/usr/include/libxml2\""
},
"dependencies": {
"CocoaAsyncSocket": [

],
"CocoaLumberjack": [

]
}
}
663 changes: 663 additions & 0 deletions CocoaHTTPServer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAEF3A461BD0012D0000509E"
BuildableName = "CocoaHTTPServer.framework"
BlueprintName = "OS X Framework"
ReferencedContainer = "container:CocoaHTTPServer.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAEF3A461BD0012D0000509E"
BuildableName = "CocoaHTTPServer.framework"
BlueprintName = "OS X Framework"
ReferencedContainer = "container:CocoaHTTPServer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAEF3A461BD0012D0000509E"
BuildableName = "CocoaHTTPServer.framework"
BlueprintName = "OS X Framework"
ReferencedContainer = "container:CocoaHTTPServer.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAEF39101BCF02870000509E"
BuildableName = "CocoaHTTPServer.framework"
BlueprintName = "iOS Framework"
ReferencedContainer = "container:CocoaHTTPServer.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAEF39101BCF02870000509E"
BuildableName = "CocoaHTTPServer.framework"
BlueprintName = "iOS Framework"
ReferencedContainer = "container:CocoaHTTPServer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAEF39101BCF02870000509E"
BuildableName = "CocoaHTTPServer.framework"
BlueprintName = "iOS Framework"
ReferencedContainer = "container:CocoaHTTPServer.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
26 changes: 26 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
14 changes: 14 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "cocoaasyncsocket",
"kind" : "remoteSourceControl",
"location" : "https://github.com/robbiehanson/CocoaAsyncSocket.git",
"state" : {
"revision" : "dbdc00669c1ced63b27c3c5f052ee4d28f10150c",
"version" : "7.6.5"
}
}
],
"version" : 2
}
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version: 5.6

import PackageDescription

let package = Package(
name: "CocoaHTTPServer",
defaultLocalization: "en",
platforms: [
.iOS(.v14),
.macOS(.v10_15)
],
products: [
.library(
name: "CocoaHTTPServer",
targets: ["CocoaHTTPServer"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/robbiehanson/CocoaAsyncSocket.git", from: "7.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "CocoaHTTPServer",
dependencies: ["CocoaAsyncSocket"]),
.testTarget(
name: "CocoaHTTPServerTests",
dependencies: ["CocoaHTTPServer"]),
]
)
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)

CocoaHTTPServer is a small, lightweight, embeddable HTTP server for Mac OS X or iOS applications.

Sometimes developers need an embedded HTTP server in their app. Perhaps it's a server application with remote monitoring. Or perhaps it's a desktop application using HTTP for the communication backend. Or perhaps it's an iOS app providing over-the-air access to documents. Whatever your reason, CocoaHTTPServer can get the job done. It provides:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CocoaHTTPServer

A description of this package.
12 changes: 1 addition & 11 deletions Samples/DynamicServer/DynamicServerAppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
#import "DynamicServerAppDelegate.h"
#import "HTTPServer.h"
#import "MyHTTPConnection.h"
#import "DDLog.h"
#import "DDTTYLogger.h"

// Log levels: off, error, warn, info, verbose
static const int ddLogLevel = LOG_LEVEL_VERBOSE;


@implementation DynamicServerAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Configure our logging framework.
// To keep things simple and fast, we're just going to log to the Xcode console.
[DDLog addLogger:[DDTTYLogger sharedInstance]];

// Initalize our http server
httpServer = [[HTTPServer alloc] init];

Expand All @@ -35,7 +25,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification

// Serve files from our embedded Web folder
NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"];
DDLogVerbose(@"Setting document root: %@", webPath);
os_log(@"Setting document root: %@", webPath);

[httpServer setDocumentRoot:webPath];

Expand Down
2 changes: 1 addition & 1 deletion Samples/DynamicServer/HTTPResponseTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ - (void)asyncStuffFinished

- (BOOL)delayResponseHeaders
{
HTTPLogTrace2(@"%@[%p] %@ -> %@", THIS_FILE, self, THIS_METHOD, (readyToSendResponseHeaders ? @"NO" : @"YES"));
HTTPLogTrace2("delayResponseHeaders -> %@", (readyToSendResponseHeaders ? @"NO" : @"YES"));

__block BOOL delayResponseHeaders = NO;

Expand Down
6 changes: 3 additions & 3 deletions Samples/DynamicServer/MyHTTPConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ @implementation MyHTTPConnection

if ([relativePath isEqualToString:@"/index.html"])
{
HTTPLogVerbose(@"%@[%p]: Serving up dynamic content", THIS_FILE, self);
HTTPLogVerbose("Serving up dynamic content", self);

// The index.html file contains several dynamic fields that need to be completed.
// For example:
Expand Down Expand Up @@ -67,7 +67,7 @@ @implementation MyHTTPConnection
[replacementDict setObject:@"A" forKey:@"ALPHABET"];
[replacementDict setObject:@" QUACK " forKey:@"QUACK"];

HTTPLogVerbose(@"%@[%p]: replacementDict = \n%@", THIS_FILE, self, replacementDict);
HTTPLogVerbose("replacementDict = \n%@", self, replacementDict);

return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
forConnection:self
Expand All @@ -76,7 +76,7 @@ @implementation MyHTTPConnection
}
else if ([relativePath isEqualToString:@"/unittest.html"])
{
HTTPLogVerbose(@"%@[%p]: Serving up HTTPResponseTest (unit testing)", THIS_FILE, self);
HTTPLogVerbose("Serving up HTTPResponseTest (unit testing)", self);

return [[HTTPResponseTest alloc] initWithConnection:self];
}
Expand Down
2 changes: 1 addition & 1 deletion Samples/PasswdHTTPServer/MyHTTPConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ - (BOOL)isPasswordProtected:(NSString *)path

BOOL result = [path hasPrefix:@"/secret"];

HTTPLogTrace2(@"%@[%p]: isPasswordProtected(%@) - %@", THIS_FILE, self, path, (result ? @"YES" : @"NO"));
HTTPLogTrace2("isPasswordProtected(%@) - %@", self, path, (result ? @"YES" : @"NO"));

return result;
}
Expand Down
Loading