Tuesday, January 11, 2011

Testing Restlet webservices from telnet

For the upcoming P2P course at Aarhus University (which I have been co-teaching for the past four years) I am currently playing around with the Restlet REST API. We want the students to learn something about peer-to-peer algorithms, protocols, and techniques, and seeing as we like a hands-on approach we always ask them to code a small P2P system as an ongoing exercise throughout the course. In past years we have asked them to do this programming using regular sockets, but that is about to change... While learning about the socket abstraction may be instrumental in teaching a coming computer scientist about the underlying constructs of the network stack, it may be time to teach them this stuff only cursory and then skip ahead to a higher level of abstraction. I mean, who (besides myself) actually works with sockets anymore?

We have therefore decided to teach the students about REST and let them use the Restlet API to create their own P2P system. But before throwing a new API at my students, I like to experiment with it myself, and I therefore dived into a little bit of Restlet programming. In the process I needed to be able to test a HTTP PUT call to my Restlet, which can not (afaik) be done easily from a webbrowser. I therefore went to my old friend telnet for help. So, if you need to test a HTTP PUT call to a webserver from telnet do the following:
telnet localhost 8182
PUT /peerlist HTTP/1.1
Host: localhost
Content-Length: 13

Hello, World!
Substitute host, URL, and content to your hearts contend.

No comments:

Post a Comment