Edit Rename Changes History Upload Download Back to Top

Smalltalk HTTP Server

Hyper

OpenSkills uses the Hyper HTTP server, a Smalltalk library available under the LGPL.

A simple example

To see Hyper work in VisualWorks, load the Hyper bundle from Store. Then start a Hyper server by evaluating the following:

    HTTPServer
        new ip: 'localhost';
        port: 8080;
        setSingleThreading;
        responseBlock: [:anHttpRequest |
            1 halt: 'Create a response here, e.g. ...'.
            HTTPResponse notFound];
        start

Point your browser to "http://localhost:8080". You should the halt pop up, and if you proceed you'll see a 404 response in the browser.

A very slightly more extended solution would have you adding an entity to an OK response. For example replace the responseBlock above with:

[:anHttpRequest |
(HttpResponse ok) entity:
'<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Hello World</title>
	</head>
	<body>
		<p>My first Web page.</p>
	</body>
</html>' asByteArray]

Resources

Monitor HTTP packets from the client or server using tcpdump. e.g:
 tcpdump -lpn -s0 -X port 2000 | less 
Gives an ASCII/hex dump of the packets going to/from port 2000.


Edit Rename Changes History Upload Download Back to Top