Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Topic/gzip #62

Merged
merged 3 commits into from

2 participants

@juanger

I added gzip support to the native extension.

I'd like you to review it and hopefully make a contribution to your cool gem.

@toland toland merged commit 2a64259 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 9, 2012
  1. @juanger
Commits on Oct 22, 2012
  1. @juanger
Commits on Oct 30, 2012
  1. @juanger
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 0 deletions.
  1. +15 −0 ext/patron/session_ext.c
View
15 ext/patron/session_ext.c
@@ -260,10 +260,25 @@ static VALUE session_unescape(VALUE self, VALUE value) {
/* Callback used to iterate over the HTTP headers and store them in an slist. */
static int each_http_header(VALUE header_key, VALUE header_value, VALUE self) {
struct curl_state *state = get_curl_state(self);
+ CURL* curl = state->handle;
+
VALUE name = rb_obj_as_string(header_key);
VALUE value = rb_obj_as_string(header_value);
VALUE header_str = Qnil;
+ if (rb_str_cmp(name, rb_str_new2("Accept-Encoding")) == 0) {
+ if (rb_funcall(value, rb_intern("include?"), 1, rb_str_new2("gzip"))) {
+ #ifdef CURLOPT_ACCEPT_ENCODING
+ curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "gzip");
+ #elif defined CURLOPT_ENCODING
+ curl_easy_setopt(curl, CURLOPT_ENCODING, "gzip");
+ #else
+ rb_raise(rb_eArgError,
+ "The libcurl version installed doesn't support 'gzip'.");
+ #endif
+ }
+ }
+
header_str = rb_str_plus(name, rb_str_new2(": "));
header_str = rb_str_plus(header_str, value);
Something went wrong with that request. Please try again.