summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@gmail.com>2016-09-24 17:50:58 +0200
committerDominik Picheta <dominikpicheta@gmail.com>2016-09-24 17:50:58 +0200
commitfa9ec7a6b54ae1fc59674f530a0ee4a7532ca5e7 (patch)
treea0db9e1f17f40166eee0816299e877ce93a8479f /tests/stdlib
parent547fb7f1e4a37ee759171834ad651d68561a7c5d (diff)
downloadNim-fa9ec7a6b54ae1fc59674f530a0ee4a7532ca5e7.tar.gz
Handle redirects in HttpClient's post procs & post test.
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/thttpclient.nim35
1 files changed, 17 insertions, 18 deletions
diff --git a/tests/stdlib/thttpclient.nim b/tests/stdlib/thttpclient.nim
index 9412a5afa..29590d9cf 100644
--- a/tests/stdlib/thttpclient.nim
+++ b/tests/stdlib/thttpclient.nim
@@ -20,6 +20,15 @@ proc asyncTest() {.async.} =
 
   resp = await client.request("https://google.com/")
   doAssert(resp.code.is2xx or resp.code.is3xx)
+
+  # Multipart test.
+  var data = newMultipartData()
+  data["output"] = "soap12"
+  data["uploaded_file"] = ("test.html", "text/html",
+    "<html><head></head><body><p>test</p></body></html>")
+  resp = await client.post("http://validator.w3.org/check", multipart=data)
+  doAssert(resp.code.is2xx)
+
   client.close()
 
   # Proxy test
@@ -41,6 +50,14 @@ proc syncTest() =
   resp = client.request("https://google.com/")
   doAssert(resp.code.is2xx or resp.code.is3xx)
 
+  # Multipart test.
+  var data = newMultipartData()
+  data["output"] = "soap12"
+  data["uploaded_file"] = ("test.html", "text/html",
+    "<html><head></head><body><p>test</p></body></html>")
+  resp = client.post("http://validator.w3.org/check", multipart=data)
+  doAssert(resp.code.is2xx)
+
   client.close()
 
   # Timeout test.
@@ -56,21 +73,3 @@ proc syncTest() =
 syncTest()
 
 waitFor(asyncTest())
-
-#[
-
-  else:
-    #downloadFile("http://force7.de/nim/index.html", "nimindex.html")
-    #downloadFile("http://www.httpwatch.com/", "ChunkTest.html")
-    #downloadFile("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com",
-    # "validator.html")
-
-    #var r = get("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com&
-    #  charset=%28detect+automatically%29&doctype=Inline&group=0")
-
-    var data = newMultipartData()
-    data["output"] = "soap12"
-    data["uploaded_file"] = ("test.html", "text/html",
-      "<html><head></head><body><p>test</p></body></html>")
-
-    echo postContent("http://validator.w3.org/check", multipart=data)]#