--[[
---------------------------------------------------------------------------
Remote Train Control Program for Windows

© Copyright 2019 by Mark DiVecchio

	This file is part of Remote Train Control.

	Remote Train Control is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Remote Train Control is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Remote Train Control.  If not, see <http://www.gnu.org/licenses/>.

 Home Page : http://www.silogic.com/trains/RTC_Running.html
---------------------------------------------------------------------------]]
-- Semicolons are not required in Lua code
--
title = "http Test"
--
-- this script requires luasocket 2.0.2 or 3.0-rc1 as
-- modified for RTC by Mark DiVecchio
-- 26 May 2019
--
-- two folders should be present in the folder
-- that contains Remote_Control.exe - 'socket' and 'mime'
--
--

-- load the http module
http = require("socket.http")

------------------------------
function setup()
print(package.path)
print(package.cpath)

-- https://love2d.org/forums/viewtopic.php?f=5&t=76728&p=159477&hilit=linux+binary
-- http://lua-users.org/lists/lua-l/2015-11/msg00355.html

-- Requests information about a document, without downloading it.
-- Useful, for example, if you want to display a download gauge and need
-- to know the size of the document in advance
r, c, h = http.request {
  method = "HEAD",
  url = "http://www.silogic.com/index.html"
}
print(r)
print(c)
print(h.date)
print(h.server)
print(h["content-length"])
-- should print the following but with current date/time/version number/size:
--1
--200
--Sun, 26 May 2019 15:39:22 GMT <<--- today's date and time
--openresty/1.13.6.2  <<-- cuurent version number
--23311  <<-- current size
--
print("Done");
return Stop();
end