From: Alexis Laferrière Date: Mon, 29 Jul 2013 19:50:52 +0000 (-0400) Subject: lib: improves testing of curl_http X-Git-Tag: v0.6.1~75^2~7 X-Git-Url: http://nitlanguage.org lib: improves testing of curl_http Signed-off-by: Alexis Laferrière --- diff --git a/examples/curl_http.nit b/examples/curl_http.nit index 50c46e5..aa84120 100644 --- a/examples/curl_http.nit +++ b/examples/curl_http.nit @@ -33,7 +33,10 @@ class MyHttpFetcher fun request(url: String): nullable CurlRequest do return self.curl.http_request(url) # Header callback - redef fun header_callback(line: String) do print "Header_callback : {line}" + redef fun header_callback(line: String) do + # We keep this callback silent for testing purposes + #if not line.has_prefix("Date:") then print "Header_callback : {line}" + end # Body callback redef fun body_callback(line: String) do print "Body_callback : {line}" @@ -106,7 +109,7 @@ else var headers = new HeaderMap headers["Accept"] = "Moo" downloadFileRequest.headers = headers - downloadFileRequest.verbose = true + downloadFileRequest.verbose = false var downloadResponse = downloadFileRequest.download_to_file(null) if downloadResponse isa CurlFileResponseSuccess then diff --git a/tests/curl_http.args b/tests/curl_http.args new file mode 100644 index 0000000..86fbf10 --- /dev/null +++ b/tests/curl_http.args @@ -0,0 +1,3 @@ +GET example.org +POST example.com +GET_FILE example.org diff --git a/tests/sav/curl_http_args1.sav b/tests/sav/curl_http_args1.sav new file mode 100644 index 0000000..c47c136 --- /dev/null +++ b/tests/sav/curl_http_args1.sav @@ -0,0 +1,52 @@ +Status code : 200 +Body : + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is established to be used for illustrative examples in documents. You may use this + domain in examples without prior coordination or asking for permission.

+

More information...

+
+ + + diff --git a/tests/sav/curl_http_args2.sav b/tests/sav/curl_http_args2.sav new file mode 100644 index 0000000..76528dd --- /dev/null +++ b/tests/sav/curl_http_args2.sav @@ -0,0 +1,54 @@ +Body_callback : + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is established to be used for illustrative examples in documents. You may use this + domain in examples without prior coordination or asking for permission.

+

More information...

+
+ + + +*** Answer *** +Status code : 200 +Body should be empty, because we decided to manage callbacks : 0 diff --git a/tests/sav/curl_http_args3.sav b/tests/sav/curl_http_args3.sav new file mode 100644 index 0000000..0c72a82 --- /dev/null +++ b/tests/sav/curl_http_args3.sav @@ -0,0 +1,3 @@ +*** Answer *** +Status code : 200 +Size downloaded : 1270