1

I'm trying to download - or even just open a stream - to a calendar located at webcal://www.somewhere.com/foo?etc=bar.

The Java URL class is throwing a "unknown protocol: webcal" exception when I do:

URL url = new URL("webcal://...");

How can I tell the URL class that it should just use HTTP as trasport protocol even if the web resource is located somewhere behind a webcal:// protocol?

Or, in any case, how can I get my calendar downloaded?

Please, bear in mind that the web server I'm calling does not serve the calendar if I try to replace the "webcal://" with "http://".

5
  • If you want to treat it as just http, why not just fix the URL? Commented Apr 12, 2013 at 9:53
  • @JonSkeet see the last sentence of the question Commented Apr 12, 2013 at 9:58
  • Ah, misread that as "does". In that case, it sounds like it's probably not just a case of using HTTP as the transport protocol. You need something which really understands webcal. Are you sure it doesn't work if you just change the rest of the URL a little, e.g. adding a fixed filename at the end? I suggest you use something like Wireshark to see what happens with a working client. Commented Apr 12, 2013 at 10:00
  • No, as I suspected was just a matter of transport. I will post the answer shortly Commented Apr 12, 2013 at 14:35
  • still waiting on that answer you promised? Commented Jan 16, 2015 at 13:32

2 Answers 2

2

As far as I understand, Apple's use of "webcal" really is just a synonym for "http"; so it's supposed to work.

Sign up to request clarification or add additional context in comments.

Comments

1

The "webcal://" is an unofficial URI scheme, see Wikipedia article on it.

As such it might stand for one or another back end implementation - e.g. the web server you are calling might be using any of the mentioned protocol implementations, such as WebDAV, CalDAV or OpenDAV

However if all you want is to read the contents of the file, then any HTTP client should do the trick, because the above mentioned protocols are based on HTTP.

Here is an example on how to read a remote iCal using URL's own mechanism for opening HttpURLConnection :

    URL calendarURL = new URL("http://www.facebook.com/ical/b.php?uid=myUID&key=myKEY");
    URLConnection connection = calendarURL.openConnection();
    BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    while (reader.ready()) {
        System.out.println(reader.readLine());
    }

As you can see I have changed the original URL from

webcal://www.facebook.com/ical/b.php?uid=MYUID&key=MYKEY

to

http://www.facebook.com/ical/b.php?uid=MYUID&key=MYKEY

, because we use a java.net.URL and by default Java does not recognize this protocol. If indeed the web server you want to contact only serves the content over webcal:// then you might need to use the appropriate client (based on the exact protocol implementation the server uses). For example there are a multitude of frameworks that provide WebDAV client capabilities, such as JackRabbit, Sardine, etc.

If you provide more information on the type of server we can dig further.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.