Posted 01 April 2013 - 01:46 PM
Background
The internet is expanding with lots of APIs designed to use HTTP's 'PUT' and 'DELETE' (also 'HEAD' & 'OPTIONS') methods as well as the classic 'GET' and 'POST', along with increasing complexity being pushed into the HTTP response codes.
Suggestion
A flexible base API for Lua libraries to build ontop of:
A way to forget about requests that are taking too long, or otherwise now unwanted:
Single event for 'done', with all the header/status information provided:
I'm not aware of how complex creating lua tables in Java is, but if it's not too painful the above header strings with newline delimiters could be converted to lua tables (as associative arrays).
Future work
Some APIs require HTTPs… I'm sure that's the start of a good joke :)/>/>
The internet is expanding with lots of APIs designed to use HTTP's 'PUT' and 'DELETE' (also 'HEAD' & 'OPTIONS') methods as well as the classic 'GET' and 'POST', along with increasing complexity being pushed into the HTTP response codes.
Suggestion
A flexible base API for Lua libraries to build ontop of:
reqid = http.send(method [string],
url [string],
user [string or nil],
password [string or nil],
headers [string 'header: value\nheader2: value2\n']
Where the 'headers' may have a blacklist of headers that can't be modified (i.e. user agent, date).A way to forget about requests that are taking too long, or otherwise now unwanted:
http.abort(reqid)
Single event for 'done', with all the header/status information provided:
local event, reqid, status, headers, sourceText = os.pullEvent()
event = 'http_ready'
reqid = (Same ID as above, up to user/library to remember/store details).
status = '200 Ok'
headers = 'Content-Type: Text/Plain\nContent-Length: 11\n'
sourceText = (same as before, filestream to read content)
I'm not aware of how complex creating lua tables in Java is, but if it's not too painful the above header strings with newline delimiters could be converted to lua tables (as associative arrays).
Future work
Some APIs require HTTPs… I'm sure that's the start of a good joke :)/>/>