bigUrl.es.tst 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. bigUrl.tst - Stress test very long URLs
  3. */
  4. const HTTP = tget('TM_HTTP') || "127.0.0.1:8080"
  5. let depth = tdepth() || 4
  6. let http: Http = new Http
  7. // Create a very long query
  8. let queryPart = ""
  9. for (i in 100) {
  10. queryPart += + "key" + i + "=" + 1234567890 + "&"
  11. }
  12. // Vary up the query length based on the depth
  13. for (iter in depth) {
  14. let query = ""
  15. for (i in 5 * (iter + 3)) {
  16. query += queryPart + "&"
  17. }
  18. query = query.trim("&")
  19. // Test /index.html
  20. http.get(HTTP + "/index.html?" + query)
  21. /*
  22. On windows, may get a connection reset as the server may respond before reading all the URL data
  23. */
  24. let status
  25. try {
  26. status = http.status
  27. if (query.length < 2000) {
  28. ttrue(http.status == 200)
  29. ttrue(http.response.contains("Hello /index.html"))
  30. } else {
  31. if (http.status != 413) {
  32. print('STATUS', http.status)
  33. dump('HEADERS', http.headers)
  34. print('response', http.response)
  35. }
  36. ttrue(http.status == 413)
  37. }
  38. } catch (e) {
  39. ttrue(e.message.contains('Connection reset'))
  40. }
  41. http.close()
  42. }