[Home]Plua/Httptest

Amatubu_Wiki | Plua | RecentChanges | Preferences

-- httptest.lua

function main()
  local ut, uf, ct, cf, gob

  ut = "default url"
  ct = ""

  ptitle("httptest")

  plabel("URL:")
  uf = pfield(1,22,50,ut)
  gob = pbutton("Go") pnl() pnl()
  cf = pfield(10,30,16383,ct)

  while 1 do
    local e, id = pevent()
    if e == ctlSelect and id == gob then
      local hc, host, path, pos
      ut = pgettext(uf)
      pos = strfind(ut, "/", 1, 1)
      if pos then
        host = strsub(ut, 1, pos-1)
        path = strsub(ut, pos)
      else
        host = ut
        path = "/"
      end

      hc = openfile("tcp:"..host..":80","rw")
      write(hc, "GET "..path.." HTTP/1.0\r\n\r\n")
      ct = read(hc, "*a")
      closefile(hc)
      psettext(cf,ct)
    end
  end
end

main()

Amatubu_Wiki | Plua | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited November 27, 2005 19:30 by Amatubu (diff)
Search:

Copyright (c) 1996-2019 naoki iimura e-mail