summaryrefslogtreecommitdiffstats
path: root/contrib/awk/awklib/eg/network/hello-serv.awk
blob: 003ee088ac445be13581475ef243873307f3ed84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
BEGIN {
  RS = ORS = "\r\n"
  HttpService = "/inet/tcp/8080/0/0"
  Hello = "<HTML><HEAD>" \
          "<TITLE>A Famous Greeting</TITLE></HEAD>" \
          "<BODY><H1>Hello, world</H1></BODY></HTML>"
  Len = length(Hello) + length(ORS)
  print "HTTP/1.0 200 OK"          |& HttpService
  print "Content-Length: " Len ORS |& HttpService
  print Hello                      |& HttpService
  while ((HttpService |& getline) > 0)
     continue;
  close(HttpService)
}
OpenPOWER on IntegriCloud