spacepaste

  1.  
  2. local uv = require( 'uv' )
  3. local http = require( 'http' )
  4. local json = require( 'json' )
  5. _G["process"] = require('process').globalProcess()
  6. config = "http://127.0.0.1:5500"
  7. config = http.parseUrl( config )
  8. config.method = "POST"
  9. config.body = json.stringify({
  10. data = {
  11. str = "test",
  12. no = 4
  13. },
  14. false
  15. })
  16. config.headers = {{"content-type", "application/json"},
  17. {"content-length",#config.body}}
  18. --config.headers["Content-Type"] = "application/json"
  19. --config.headers["Content-Length"] = #config.body
  20. local req = http.request( config, p )
  21. req:done()
  22. uv.run()
  23.