get.es.tst 772 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. get.tst - Http GET tests
  3. */
  4. const HTTP = tget('TM_HTTP') || "127.0.0.1:8080"
  5. let http: Http = new Http
  6. // Basic get. Validate response code and contents
  7. http.get(HTTP + "/index.html")
  8. ttrue(http.status == 200)
  9. // ttrue(http.readString().contains("Hello"))
  10. // Validate get contents
  11. http.get(HTTP + "/index.html")
  12. ttrue(http.readString(12) == "<html><head>")
  13. // Validate get contents
  14. http.get(HTTP + "/index.html")
  15. ttrue(http.response.endsWith("</html>\n"))
  16. ttrue(http.response.endsWith("</html>\n"))
  17. // Test Get with a body. Yes this is valid Http, although unusual.
  18. http.get(HTTP + "/index.html", 'name=John&address=700+Park+Ave')
  19. ttrue(http.status == 200)
  20. if (Config.OS == "windows") {
  21. http.get(HTTP + "/inDEX.htML")
  22. ttrue(http.status == 200)
  23. }