uri.es.tst 732 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. Uri validation
  3. */
  4. const HTTP: Uri = tget('TM_HTTP') || "127.0.0.1:8080"
  5. function get(uri): String {
  6. let s = new Socket
  7. s.connect(HTTP.address)
  8. let count = 0
  9. try {
  10. count += s.write("GET " + uri + " HTTP/1.0\r\n\r\n")
  11. } catch {
  12. tfail("Write failed. Wrote " + count + " of " + data.length + " bytes.")
  13. }
  14. let response = new ByteArray
  15. while ((n = s.read(response, -1)) != null ) {}
  16. s.close()
  17. return response.toString()
  18. }
  19. /*
  20. let response
  21. response = get('index.html')
  22. ttrue(response.toString().contains('Not Found'))
  23. response = get('/\x01index.html')
  24. ttrue(response.toString().contains('Bad Request'))
  25. */
  26. response = get('\\index.html')
  27. ttrue(response.toString() == '')