Sunday, August 3, 2008

Cocoa HTTPServer on iPhone

The open source Cocoa HTTP Server has been updated to be compatible with the iPhone. You can find it at its google code page.


Brian said...

Short question: how hard would it be to add WebDav support to the server for use on the iPhone?

I came across this iPhone app, Air Server, which has a webdav server built-in and allows uploading files to the phone in a simple fashion.

I'm working on an iPhone app that is a kind of viewer app for a specific kind of data file. The users, of course, need to be able to upload their files to the phone to be viewed there. I've currently implemented a 'download from web site' functionality. I was planning on adding support for an 'upload to the phone' functionality based on your http server and a simple upload files form on a web page that would be served by my app. It seems that WebDav is superior to this method.

Do you agree? Is WebDav better than a 'form-based upload files method'. Would it be straightforward to add (maybe minimul) WebDav support to your server? Is someone already working on this?

Robbie Hanson said...

Hi Brian,

WebDAV is certainly a good idea.

I know of 3 developers that have contacted me regarding adding WebDAV support. One of them recently emailed me, and said they'd finished a WebDAV implmenetation and would be sending me the code so I could add it to the official project. And I believe another developer has also finished their implementation, and may offer support on getting WebDAV into the official source tree.

I'll keep you posted. :)

Matej Knopp said...
This comment has been removed by the author.
Matej Knopp said...

Any news on this? Would be awesome to have a webdav support in cocoa HTTPServer.

Robbie Hanson said...

The latest news is that the author has told me he/she plans on sending me the WebDAV code this weekend maybe. So I may be working on adding it to the google code project as early as this weekend.

Ryan McCormack said...

Any latest word on WebDAV support?

ClickSpace said...

This would be FANTASTIC to have a Cocoa based WebDAV server for the iPhone! I think there are tons of developers who would love to have this for their iPhone apps. Myself included! I've been trying to get lighttpd to work, but it's way more complicated to use than having an embedded server.

lighttpd compiles as an executable, not as a shared library and I think it would require something like NSTask to be able to spawn it as a separate process. I don't know if Apple would approve of that. I know that the Air Sharing guys are using it, but I believe they did a lot of work to get it to compile into their project. They certainly have more skills in that area than I do.

But having WebDAV accessible from a Cocoa app would make building a backup/restore & import/export function for my Tap Forms app much much easier. So far I've managed to get SyncDocs working, but I don't like the Java client interface or process. Having WebDAV built-in to my app would be way nicer and more convenient for my customers.

From reading the above posts, it was suggested that you would have received the WebDAV code from a couple of developers back in September. Is there any further progress on that front?


Chris said...

I too am very interested in the possibility of a WebDAV library as is discussed here. Any followup?

ClickSpace said...

So no further info on availability of the WebDAV module?

Anonymous said...

just a bump of curiosity on the possibility of webdav on the iphone,... any progress?

Robbie Hanson said...

Here's the latest news on WebDAV:

The author of the code has sent me the modifications he needed to make to the regular HTTPServer classes. We've synced up on these changes now, and the resulting work has been committed.

I've been told, "Once I see my way clear of my current pile of work I will be back to working on WebDAV support and we can sync up on that."

I had no idea WebDAV would be so popular. I've received at least 2 dozen emails from people asking about it. I finally emailed the author again to inform him of the widespread interest, and I was told "I would love to be working on that right now - it's a matter of priorities."

I understand where he's coming from. There are often times I'd like to be working on some open source project, but internal deusty stuff necessarily takes priority. As such, I've been trying my best not to bug him further.

I sincerely apologize to all who have been waiting patiently for this. I had no idea WebDAV would be so popular.

Anonymous said...

thanks for the update!

ClickSpace said...

I just looked at the Welcome document in an app called "Files Lite" available now on the App Store and it says in there "WebDAV server based on CocoaHTTPServer from Deusty Designs". I didn't think WebDAV support was in there just yet.

The company that makes Files List is called olivetoast at

Maybe he/she will submit his changes back to Cocoa HTTP Server.

Caragea Silviu said...

Any news about webdav?

ClickSpace said...

I'm still hoping the solution will be released. Either that or we all need to re-invent the wheel and build our own webdav servers for the iPhone. I've been experimenting with the Diddy FTP server code, although it's very good, it's not as elegant a solution as webdav since with webdav you don't need an FTP client program for it to work. Plus there's the issue of authentication.

Well, maybe it's about time I start to read up on the webdav protocol to see what would need to be changed in CocoaHTTP Server to make it work. Unfortunately it's been a LONG time since I did any network protocol programming... Hmm... now where's that assignment I worked on in University oh about 20 years ago in my network technologies course?

Anonymous said...

I'd be willing to put my time into developing this, if the existing solution is seeing next to no movement towards being published... My first problem is where to start, anyone have a good reference on WebDAV implementation?

Robbie Hanson said...

I finally broke down and emailed the author again, asking if there was any news on the WebDAV stuff. I've been told, "Nothing new - this is still not the highest priority in my queue." :(

Anonymous said...

blah, sounds like its time to re-invent the wheel...

ClickSpace said...

I asked the author of Files Lite if they would be releasing their WebDAV code back to the Cocoa HTTPServer project, but they understandably said they weren't going to, at least not in the near future. But they also said they wouldn't rule it out at some future point in time. But nothing soon. I guess they're making money off it and wouldn't want to jeopardize that. I can understand that. As soon as there's an open source WebDAV solution, all those guys with file storage applications might not be happy about it.

I've already added that type of thing to my application, but using the open source Diddy FTP software. At least until there's a WebDAV solution.

Here's a link to the WebDAV specs:

lukas said...

Absolutely great work! Thanks for this. I have a question though: I'm currently trying to incorporate your code in my iPhone project. As custom frameworks are a no go, I added SSCrypto as source files. But of course they don't compile because all the openssl stuff is missing... How should I do this?

Robbie Hanson said...

Hi Lukas,

Make sure to check out the latest version of the code. It includes a file, DDData.m, that compiles using SSCrypto for Mac, and CommonCrypto for iPhone. All crypto code in the HTTP server project uses the methods in this file for proper compatibility.


Dallas Brown said...

It's been another month (plus) any new news on WebDav support or has anyone recreated the wheel in another library? I am VERY interested in adding WebDav to my app as right now my transfer solution is Mac only.

Robbie Hanson said...

It seems the author who originally promised to email me his WebDAV implementation has changed his mind. There are, however, others who may be working on it. You may find this thread interesting.

In addition to discussing those who may be working on WebDAV for CocoaHTTPServer, it also discusses the cons of WebDAV. In particular, one author who spent a long time working with WebDAV, only to realize it was a dead end, with a poor API, and poor support on Mac.

There are many other options available. Have you seen this post?

softbump said...

Take a look on this WebDAV library for iPhone , a best solution which allow you to Transfers Files Between iPhones and Any System.

ניצה ואברהם said...

First, Happy 2010 to all.
I use iPhone WiFi connected to my router. Same router serves few computers in my LAN for internet and others.
All computers can see each other except the iphone. Using the file viewer which uses your application to transfer files from computer to iPhone. I followed instruction and enter in the computer browser the iPhone IP address (which is internal IP but cant get the connection.
Can you advise ? abraham on abrahamlevyg@gmail.comThanks

ניצה ואברהם said...

Having in mind that may be previous application is not ok, downloaded the iFiles application. Again I can't connect from PC to the iPhone...
Abraham Levy

piprog said...

Hi Robbie,

Any recent updates on webDAV support?


Baskaran said...

What happend to SoftBump? The site still says under construction. What if I want to use their library in my application?

I am not sure if this company is bought over by some 'big' guys for the fear of getting stiff competition.

ClickSpace said...

That's exactly what happened. SoftBump's code got purchased by some other unknown development company who wanted to keep it to themselves. I was lucky enough to have purchased a license before this happened. But if one day the library doesn't work anymore, I will probably be screwed. I sure hope not though. The developer did say he would support me if that were to happen, but the last time I tried to contact him, there was no reply.


Brendan Duddridge

Baskaran said...

You might have a look at
This has WebDAV built in and it supposed to be complete.

iphonemobdev said...

Hi Robbie,

It really great code and help us lot.

But sometimes it crashes after uploading one time. Do you know what to do?


Robbie Hanson said...

Hi iphonemobdev,

The iPhone upload code is the only file I didn't have a hand in. I'd like to eventually write a full POST parsing class, but I likely won't have any time to do so for quite a while. You might try taking a look at the mailing list.

iphonemobdev said...


Can you please guide me on some issues.

1. I want to allow user to upload only specific file. Where can i do this? . I tried a lot to prevent in - (NSObject *)httpResponseForMethod:(NSString *)method URI:(NSString *)path method but still it get upload anything.

2. And if user upload any file then i prevent the user as above and want to give pop up alert like normal server on the browser,. Can you please guide me on that issues.

I thought before that it would be easy to do but i tried a lot but i could not do. Its really urgent for me.

Many Thanks.

Steve said...

Hi Guys,

I have an iPhone app that uses cocoaHTTPServer. I've written a Windows client in C# to upload files to the iPhone. The code I've written works fine with small files, but crashes with larger files.

Using a browser to upload the same file works fine.

Does anyone have any C# code for uploading files to cocoaHTTPServer that works with large files?


Rwatkins said...

Thank you for all your posts. I've been reading through them looking through all my options for incorporating webdav into my iphone app.

I was wondering if anyone has come up with something new. Their is the MobileME iDisk app and Quick Office has incorporated webdav with iDisk, google docs, and more so easily. Is there any way to jump off these ideas or has Apple incorporated a packet that we can call to at least make iDisk easily available in an app?

Simply I am trying to make iDisk and google docs available to pull docs from. If there is another option outside of webdav I am open to other options.

Mr Burns said...

Hmm imported two small files into my iPhone app successfully , but crashed when trying to import a large file.

Can someone help me? I can provide more info on the crash if anyone cares to lend some insight.

(running iOS4 on iPhone 4)
(3.1.3 on iPhone 2G)

djose said...

Hi Robbie,
Great work !!. I was trying to make cocoahttpserver a staging platfom between an external nodejs server and the safari browser, is it possible to initiate a connection from the cocoahttpserver to nodejs server using socketIO. The idea is to make cocoahttp server as a client to the Nodejs and a server to safari at the same time