From 5af777c849be79222f0ffba8d32f5ffec6f6969a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Wed, 2 Apr 2014 16:50:35 -0400 Subject: [PATCH] lib/curl: add support for setting the user agent MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/curl/curl.nit | 6 ++++++ lib/curl/curl_c.nit | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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; `} -- 1.7.9.5