huge-uri.es.tst 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. Very large URI test
  3. */
  4. const HTTP: Uri = tget('TM_HTTP') || "127.0.0.1:8080"
  5. // This writes a ~100K URI. LimitUri should be less than 100K for this unit test.
  6. let data = "/"
  7. for (i in 1000) {
  8. data += "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\n"
  9. }
  10. /*
  11. Test LimitUri
  12. */
  13. let s = new Socket
  14. s.connect(HTTP.address)
  15. let count = 0
  16. try {
  17. count += s.write("GET ")
  18. count += s.write(data)
  19. count += s.write(" HTTP/1.1\r\n\r\n")
  20. } catch {
  21. // App.log.error("Write failed. Wrote " + count + " of " + data.length + " bytes.")
  22. }
  23. /* Server should just close the connection without a response */
  24. response = new ByteArray
  25. while ((n = s.read(response, -1)) != null) { }
  26. if (response.length > 0) {
  27. /* May not get a response if the write above fails. Then we get a conn reset */
  28. ttrue(response.toString().contains('413 Request too large'))
  29. }
  30. s.close()
  31. // Check server still up
  32. http = new Http
  33. http.get(HTTP + "/index.html")
  34. ttrue(http.status == 200)
  35. http.close()