From: Alexis Laferrière Date: Wed, 2 Apr 2014 20:50:35 +0000 (-0400) Subject: lib/curl: add support for setting the user agent X-Git-Tag: v0.6.6~127^2~2 X-Git-Url: http://nitlanguage.org lib/curl: add support for setting the user agent Signed-off-by: Alexis Laferrière --- diff --git a/lib/curl/curl.nit b/lib/curl/curl.nit index 1c1f4cc..33b56a9 100644 --- a/lib/curl/curl.nit +++ b/lib/curl/curl.nit @@ -80,6 +80,12 @@ class CurlHTTPRequest var datas: nullable HeaderMap writable = null var headers: nullable HeaderMap writable = null + # Set the user agent for all following HTTP requests + fun user_agent=(name: String) + do + curl.prim_curl.easy_setopt(new CURLOption.user_agent, name) + end + init (url: String, curl: nullable Curl) do self.url = url diff --git a/lib/curl/curl_c.nit b/lib/curl/curl_c.nit index ee64844..1dd3da9 100644 --- a/lib/curl/curl_c.nit +++ b/lib/curl/curl_c.nit @@ -483,7 +483,7 @@ extern CURLOption `{ CURLoption `} new postfields `{ return CURLOPT_POSTFIELDS; `} # new `{ return CURLOPT_REFERER; `} # new `{ return CURLOPT_FTPPORT; `} -# new `{ return CURLOPT_USERAGENT; `} + new user_agent `{ return CURLOPT_USERAGENT; `} # new `{ return CURLOPT_LOW_SPEED_LIMIT; `} # new `{ return CURLOPT_LOW_SPEED_TIME; `} # new `{ return CURLOPT_RESUME_FROM; `}