      subroutine httpget.sub(host,url,res,err)
*
*
*
*
*
*
*
*
*
$catalog local

      crlf = char(13) : char(10)

      res = ''
      err = ''
      eof = 0

      if not(index(host,':',1)) then host = host : ':80'
      call sock.connect(host,'',sockfd,err)

      if err <> '' then return

      if url[1,1] <> '/' then url = '/' : url

      obuf = 'GET ' : url : ' HTTP/1.0'
      obuf<-1> = 'User-Agent: OpenQM 1.0'
      obuf<-1> = 'Server: ' : host

      obuf = change(obuf,@am,crlf) : crlf : crlf

      call sock.write(sockfd,obuf,120000,err)

      if err <> '' then return

      call sock.read(sockfd,5000000,600000,crlf:crlf,ibuf,err)

      if err = 'EOF' then
         eof = 1
         err = ''
      end

      if err <> '' then return

      loop while ibuf[1,2] = crlf do
         ibuf = ibuf[3,999999999]
      repeat

      t = index(ibuf,crlf:crlf,1)

      if not(t) then
         call csub.close(sockfd,'')
         err = 'HTTP header not returned.'
         return
      end

      hdr = ibuf[1,t-1]
      ibuf = ibuf[t+4,999999999]

      hdr = change(hdr,crlf,@am)
      print 'hdr = ' : hdr

      call csub.close(sockfd,'')

      return
   end
