WebDAV

47 views
Skip to first unread message

BrendanD

unread,
Nov 6, 2008, 4:04:35 AM11/6/08
to CocoaHTTPServer
Hey,

Just thought I'd chime in here to see if there's been any more
discussions or code released on including WebDAV support into
CocoaHTTPServer.

Thanks,

Brendan

bangzippy

unread,
Dec 1, 2008, 11:31:25 AM12/1/08
to CocoaHTTPServer
Hi Brendan

I have been working on a web dav implementation is there is enough
interest. I would have to port it to cocoahttp first.

Does anyone know, can CocoaHTTP use the runLoop? I want to embed the
server in my GUI app. It is important that my UI continue to work
while the server is running.

thanks

andy

BrendanD

unread,
Dec 1, 2008, 6:50:25 PM12/1/08
to CocoaHTTPServer
Hi Andy,

Yes, I believe that CocoaHTTPD can run like that as it uses
AsyncSockets for its communication layer, which does not block.

You can find more information on it at: http://code.google.com/p/cocoaasyncsocket/

From that site:

Queued non-blocking reads and writes, with optional timeouts. You tell
it what to read or write, and it will call you when it's done.

Automatic socket acceptance. If you tell it to accept connections, it
will call you with new instances of itself for each connection. You
can, of course, disconnect them immediately.

Delegate support. Errors, connections, accepts, read completions,
write completions, progress, and disconnections all result in a call
to your delegate method.

Run-loop based, not thread based. Although you can use it on main or
worker threads, you don't have to. It calls the delegate methods
asynchronously using NSRunLoop. The delegate methods include a socket
parameter, allowing you to distinguish between many instances.

Self-contained in one class. You don't need to muck around with
streams or sockets. The class handles all of that.

Support for TCP streams over IPv4 and IPv6.

I'd be interested in helping you out with your WebDAV solution. I
think CocoaHTTPD is a good solution as it is small and simple. In
fact, it is used by the Files and Files Lite applications already
available on the App Store.

Thanks,

Brendan

Andrew Davidson

unread,
Dec 1, 2008, 11:29:38 PM12/1/08
to cocoaht...@googlegroups.com
Hi Brendan

Is there are reason you want to use webDAV? I have wasted a lot of time
trying to implement it. The Finder on MacOS supports webDAV but is very
unforgiving. The slightest mistake will cause your entire computer to hang!
You will have to pull the power cord!!!!
I have implemented OPTIONS, PROPFIND, MOVE, COPY, DELETE. a stub for LOCK,
UNLOCK. I also implemented GET,PUT, and POST for small files. I have not
implemented PROPFIND. PROPFIND is used by windows xp. I still have a lot of
work to do to get this to work with windows xp, and linux

In general webDAV is a very lame protocol. Most of the clients are very
buggy. The spec is poorly written resulting in poor interopablity between
various clients. I started implementing it because I need a way to transfer
files between a computer and the iphone. Every one on I asked said use
webDAV, its easy. Over the week end I came to realize I would probably be a
lot easier to just implement an HTTP server. You provide an implementation
of get that returns an html page allowing users to get files, or provides a
directory listing, the directory list html allows user to delete individual
files, add a sub dir, upload a file.

Here is a high level spec for implementing get

- if URL is for a a file, return file
- if URL is for a directory, return html directory listing as follows

<H1> directory path</h1>

For each entry in directory (include .. to navigate to parent)

If file
<li><a href="url">file name size</> <button
onclick="location=./url?delete">delete</button></li>

If dir
<li>a href="url><img src="folder.jpg>dir name</> button
onclick="location=./url?delete">delete</button></li>

At the bottom of the html
Create a form to enable users to upload files

<form id="uploadForm" action="http://your service.com" method="post"
enctype="multipart/form-data" autocomplete="off">
<input id="file" name="input" size="41" type="file" />
</form>

Add another form to allow users to create a sub dir.

I have not implemented this myself yet. It seems dramatically easier if you
already have a good web server.

The only reason I can think to use webDAV is if you needed file level
locking for some reason.

Let me know what you decide to do

Andy

BrendanD

unread,
Dec 2, 2008, 3:08:29 AM12/2/08
to CocoaHTTPServer
Hello Andy,

Well, I already have FTP in my application ready to go, but I thought
WebDAV seemed like a more elegant solution since there's no desktop
FTP client application required. I thought it would be simpler for the
customer. There are lots of programs in the App Store that are using
WebDAV, so I thought it was something doable. But if you say that it
has all kinds of problems as a protocol, then perhaps it's not worth
the trouble.

I basically need a way of getting files on and off the iPhone into and
out of my app for import and export purposes.

Perhaps if you submit your WebDAV code to this project, others can
help implement it and then all iPhone apps would have the chance to
have an easy to integrate solution to provide this capability.

Thanks,

Brendan

On Dec 1, 9:29 pm, "Andrew Davidson" <a...@santacruzintegration.com>
wrote:
> <form id="uploadForm" action="http://yourservice.com" method="post"

Turin

unread,
Dec 12, 2008, 4:02:22 PM12/12/08
to CocoaHTTPServer

I think WebDav is a must these days. TouchHTTP is going to include a
WebDav server.

dont give up!

turin
> > > > Brendan- Hide quoted text -
>
> - Show quoted text -

Andrew Davidson

unread,
Dec 12, 2008, 9:35:47 PM12/12/08
to cocoaht...@googlegroups.com
webDAV is very very difficult to implement and debug. If you make the
slightest little mistake in what you send back to Mac OS finder, your entire
computer will lock up. You will have to pull the power cord out and reboot!.
This problem has been confirmed by Apple

Andrew Davidson

unread,
Dec 12, 2008, 9:46:56 PM12/12/08
to cocoaht...@googlegroups.com
I forgot to mention. I wasted about a month using TouchHTTP. The webDAV spec
is based on http/1.1 unfortunately TouchHTTP does not implement 1.1 :-( I
only found out after I wasted a lot of time TouchHTTP is very complicated.

The TouchHTTP based code actually works for Mac OS using HTTP 1.0 how ever
this is not going to work well with other webDAV clients

I started writing a stand along http 1.1 server. I spent about a week before
I discovered cocoahttpserver. Cocoahttpserver is much better than my server.
My server has some sort of bug I have not been able to figure out. It gets
to a point in the initial exchange of OPTION and PROPFIND where go to write
a response to the client and the socket gets/is closed. I am not sure what
is going on, or why the connection might go stale. Let alone how to know if
the connection is stale or not.

If someone is really interested, I can post the webDAV part of the two
implementations.

In general the way I figure out what by reading the spec and looking at what
other webDAV server do by using wireshark to look at the tcp/ip packets.

I have not had the time to port my webDAV partial implementation over to
cocoahttpserver. Plus it looks like Nonnus is making a lot of progress! Way
to go Nonnus!

Andy

-----Original Message-----
From: cocoaht...@googlegroups.com
[mailto:cocoaht...@googlegroups.com] On Behalf Of Turin
Reply all
Reply to author
Forward
0 new messages