Permalink
Browse files

Adds support for curls ignore-content-length option

  • Loading branch information...
1 parent 0b0f8fd commit 641213184e89b69ebac188bc0689ba34e1622f87 Michael Amygdalidis committed with taf2 Oct 5, 2010
Showing with 39 additions and 0 deletions.
  1. +31 −0 ext/curb_easy.c
  2. +1 −0 ext/curb_easy.h
  3. +7 −0 tests/tc_curl_easy.rb
View
@@ -197,6 +197,7 @@ static void ruby_curl_easy_zero(ruby_curl_easy *rbce) {
rbce->verbose = 0;
rbce->multipart_form_post = 0;
rbce->enable_cookies = 0;
+ rbce->ignore_content_length = 0;
}
/*
@@ -1599,6 +1600,31 @@ static VALUE ruby_curl_easy_enable_cookies_q(VALUE self) {
CURB_BOOLEAN_GETTER(ruby_curl_easy, enable_cookies);
}
+/*
+ * call-seq:
+ * easy.ignore_content_length = boolean
+ *
+ * Configure whether this Curl::Easy instance should ignore the content
+ * length header.
+ */
+static VALUE ruby_curl_easy_ignore_content_length_set(VALUE self, VALUE ignore_content_length)
+{
+ CURB_BOOLEAN_SETTER(ruby_curl_easy, ignore_content_length);
+}
+
+/*
+ * call-seq:
+ * easy.ignore_content_length? => boolean
+ *
+ * Determine whether this Curl::Easy instance ignores the content
+ * length header.
+ */
+static VALUE ruby_curl_easy_ignore_content_length_q(VALUE self) {
+ CURB_BOOLEAN_GETTER(ruby_curl_easy, ignore_content_length);
+}
+
+
+
/* ================= EVENT PROCS ================== */
/*
@@ -1902,6 +1928,9 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, rbce->connect_timeout);
curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, rbce->dns_cache_timeout);
+ curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, rbce->ignore_content_length);
+
+
#if LIBCURL_VERSION_NUM >= 0x070a08
curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, rbce->ftp_response_timeout);
#else
@@ -3316,6 +3345,8 @@ void init_curb_easy() {
rb_define_method(cCurlEasy, "multipart_form_post?", ruby_curl_easy_multipart_form_post_q, 0);
rb_define_method(cCurlEasy, "enable_cookies=", ruby_curl_easy_enable_cookies_set, 1);
rb_define_method(cCurlEasy, "enable_cookies?", ruby_curl_easy_enable_cookies_q, 0);
+ rb_define_method(cCurlEasy, "ignore_content_length=", ruby_curl_easy_ignore_content_length_set, 1);
+ rb_define_method(cCurlEasy, "ignore_content_length?", ruby_curl_easy_ignore_content_length_q, 0);
rb_define_method(cCurlEasy, "on_body", ruby_curl_easy_on_body_set, -1);
rb_define_method(cCurlEasy, "on_header", ruby_curl_easy_on_header_set, -1);
View
@@ -67,6 +67,7 @@ typedef struct {
char verbose;
char multipart_form_post;
char enable_cookies;
+ char ignore_content_length;
struct curl_slist *curl_headers;
struct curl_slist *curl_ftp_commands;
@@ -476,6 +476,13 @@ def test_multipart_form_post
assert c.multipart_form_post?
end
+ def test_ignore_content_length
+ c = Curl::Easy.new
+ assert !c.ignore_content_length?
+ assert c.ignore_content_length = true
+ assert c.ignore_content_length?
+ end
+
def test_enable_cookies
c = Curl::Easy.new
assert !c.enable_cookies?

0 comments on commit 6412131

Please sign in to comment.