Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 6625620c8f

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
English.lproj
PasswdHTTPServer.xcodeproj
AppDelegate.h
AppDelegate.m
Info.plist
MyHTTPConnection.h
MyHTTPConnection.m
PasswdHTTPServer_Prefix.pch
README.markdown
main.m

README.markdown

INFO:

This project demonstrates password protecting a specific resource. More specifically, the project allows unrestricted access to the ~/Sites folder, but requires a password for anything in the ~/Sites/secret/ subfolder.

INSTRUCTIONS:

Create the following folder: ~/Sites/secret

And then add a file to it. For example: ~/Sites/secret/doc.txt

Open the Xcode project, and build and go.

On the Xcode console you'll see a message saying something like: "Started HTTP server on port 59123"

The actual port the server uses is not hard-coded. You can hard-code it if you want, but by default it will just allow the operating system to provide an available port.

Now open your browser and type the URL (replacing with the proper port):
http://localhost:59123

Notice that it displays your file without password prompt:
~/Sites/index.html

Now type the URL (replacing with password prompt):
http://localhost:59123/secret/doc.txt

Notice that it prompts you for a username/password. The sample code accepts any username, and the password is "secret".

(Replace 59123 with whatever port the server is actually running on.)

Enjoy.

Something went wrong with that request. Please try again.