]> granicus.if.org Git - curl/commitdiff
CURLINFO_RESPONSE_CODE.3: add example
authorDaniel Schauenberg <d@unwiredcouch.com>
Sun, 17 Jan 2016 04:04:46 +0000 (23:04 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Sun, 17 Jan 2016 04:05:07 +0000 (23:05 -0500)
docs/libcurl/opts/CURLINFO_RESPONSE_CODE.3

index e060872397f8e6342becc8ff8a5982dcc2759ef2..60a12a9fbbb527777e5a4946f49ab4b1a6c28b0a 100644 (file)
@@ -38,7 +38,19 @@ Support for SMTP responses added in 7.25.0.
 .SH PROTOCOLS
 HTTP, FTP and SMTP
 .SH EXAMPLE
-TODO
+.nf
+CURL *curl = curl_easy_init();
+if(curl) {
+  CURLcode res;
+  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
+  res = curl_easy_perform(curl);
+  if(res == CURLE_OK) {
+    long response_code;
+    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
+  }
+  curl_easy_cleanup(curl);
+}
+.fi
 .SH AVAILABILITY
 Added in 7.10.8. CURLINFO_HTTP_CODE was added in 7.4.1.
 .SH RETURN VALUE