curb 1.2.2 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/curb_easy.h CHANGED
@@ -42,6 +42,7 @@ typedef struct {
42
42
  VALUE self; /* owning Ruby object */
43
43
  VALUE opts; /* rather then allocate everything we might need to store, allocate a Hash and only store objects we actually use... */
44
44
  VALUE multi; /* keep a multi handle alive for each easy handle not being used by a multi handle. This improves easy performance when not within a multi context */
45
+ VALUE callback_error; /* preserves body/header callback exceptions without mutating the Ruby object */
45
46
 
46
47
  /* Other opts */
47
48
  unsigned short local_port; // 0 is no port
@@ -64,6 +65,7 @@ typedef struct {
64
65
  long ssl_version;
65
66
  long use_ssl;
66
67
  long ftp_filemethod;
68
+ long http_version;
67
69
  unsigned short resolve_mode;
68
70
 
69
71
  /* bool flags */
@@ -87,14 +89,17 @@ typedef struct {
87
89
  struct curl_slist *curl_ftp_commands;
88
90
  struct curl_slist *curl_resolve;
89
91
 
92
+ unsigned long multi_attachment_generation;
90
93
  int last_result; /* last result code from multi loop */
91
94
 
92
95
  } ruby_curl_easy;
93
96
 
94
97
  extern VALUE cCurlEasy;
98
+ extern const rb_data_type_t ruby_curl_easy_data_type;
95
99
 
96
100
  VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce);
97
101
  VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce);
102
+ VALUE rb_curl_easy_take_callback_error(ruby_curl_easy *rbce);
98
103
 
99
104
  void init_curb_easy();
100
105
 
data/ext/curb_errors.c CHANGED
@@ -119,7 +119,7 @@ VALUE mCurlErrBadEasyHandle;
119
119
  VALUE mCurlErrOutOfMemory;
120
120
  VALUE mCurlErrInternalError;
121
121
  VALUE mCurlErrBadSocket;
122
- #if HAVE_CURLM_ADDED_ALREADY
122
+ #ifdef HAVE_CURLM_ADDED_ALREADY
123
123
  VALUE mCurlErrAddedAlready;
124
124
  #endif
125
125
  VALUE mCurlErrUnknownOption;
@@ -561,17 +561,17 @@ VALUE rb_curl_multi_error(CURLMcode code) {
561
561
  case CURLM_INTERNAL_ERROR: /* 4 */
562
562
  exclz = mCurlErrInternalError;
563
563
  break;
564
- #if HAVE_CURLM_BAD_SOCKET
564
+ #ifdef HAVE_CURLM_BAD_SOCKET
565
565
  case CURLM_BAD_SOCKET: /* 5 */
566
566
  exclz = mCurlErrBadSocket;
567
567
  break;
568
568
  #endif
569
- #if HAVE_CURLM_UNKNOWN_OPTION
569
+ #ifdef HAVE_CURLM_UNKNOWN_OPTION
570
570
  case CURLM_UNKNOWN_OPTION: /* 6 */
571
571
  exclz = mCurlErrUnknownOption;
572
572
  break;
573
573
  #endif
574
- #if HAVE_CURLM_ADDED_ALREADY
574
+ #ifdef HAVE_CURLM_ADDED_ALREADY
575
575
  case CURLM_ADDED_ALREADY: /* 7 */
576
576
  exclz = mCurlErrAddedAlready;
577
577
  break;
@@ -709,7 +709,7 @@ void init_curb_errors() {
709
709
  mCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "MultiOutOfMemory", eCurlErrError);
710
710
  mCurlErrInternalError = rb_define_class_under(mCurlErr, "MultiInternalError", eCurlErrError);
711
711
  mCurlErrBadSocket = rb_define_class_under(mCurlErr, "MultiBadSocket", eCurlErrError);
712
- #if HAVE_CURLM_ADDED_ALREADY
712
+ #ifdef HAVE_CURLM_ADDED_ALREADY
713
713
  mCurlErrAddedAlready = rb_define_class_under(mCurlErr, "MultiAddedAlready", eCurlErrError);
714
714
  #endif
715
715
  mCurlErrUnknownOption = rb_define_class_under(mCurlErr, "MultiUnknownOption", eCurlErrError);
data/ext/curb_errors.h CHANGED
@@ -116,7 +116,7 @@ extern VALUE mCurlErrOutOfMemory;
116
116
  extern VALUE mCurlErrInternalError;
117
117
  extern VALUE mCurlErrBadSocket;
118
118
  extern VALUE mCurlErrUnknownOption;
119
- #if HAVE_CURLM_ADDED_ALREADY
119
+ #ifdef HAVE_CURLM_ADDED_ALREADY
120
120
  extern VALUE mCurlErrAddedAlready;
121
121
  #endif
122
122
 
data/ext/curb_macros.h CHANGED
@@ -25,7 +25,7 @@
25
25
  #define CURB_OBJECT_SETTER(type, attr) \
26
26
  type *ptr; \
27
27
  \
28
- Data_Get_Struct(self, type, ptr); \
28
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
29
29
  ptr->attr = attr; \
30
30
  \
31
31
  return attr;
@@ -34,14 +34,14 @@
34
34
  #define CURB_OBJECT_GETTER(type, attr) \
35
35
  type *ptr; \
36
36
  \
37
- Data_Get_Struct(self, type, ptr); \
38
- return ptr->attr;
37
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
38
+ return ptr->attr;
39
39
 
40
40
  /* setter for anything that stores a ruby VALUE in the struct opts hash */
41
41
  #define CURB_OBJECT_HSETTER(type, attr) \
42
42
  type *ptr; \
43
43
  \
44
- Data_Get_Struct(self, type, ptr); \
44
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
45
45
  rb_hash_aset(ptr->opts, rb_easy_hkey(#attr), attr); \
46
46
  \
47
47
  return attr;
@@ -50,13 +50,13 @@
50
50
  #define CURB_OBJECT_HGETTER(type, attr) \
51
51
  type *ptr; \
52
52
  \
53
- Data_Get_Struct(self, type, ptr); \
54
- return rb_hash_aref(ptr->opts, rb_easy_hkey(#attr));
53
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
54
+ return rb_hash_aref(ptr->opts, rb_easy_hkey(#attr));
55
55
 
56
56
  /* setter for bool flags */
57
57
  #define CURB_BOOLEAN_SETTER(type, attr) \
58
58
  type *ptr; \
59
- Data_Get_Struct(self, type, ptr); \
59
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
60
60
  \
61
61
  if (attr == Qnil || attr == Qfalse) { \
62
62
  ptr->attr = 0; \
@@ -69,7 +69,7 @@
69
69
  /* getter for bool flags */
70
70
  #define CURB_BOOLEAN_GETTER(type, attr) \
71
71
  type *ptr; \
72
- Data_Get_Struct(self, type, ptr); \
72
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
73
73
  \
74
74
  return((ptr->attr) ? Qtrue : Qfalse);
75
75
 
@@ -78,7 +78,7 @@
78
78
  type *ptr; \
79
79
  VALUE oldproc; \
80
80
  \
81
- Data_Get_Struct(self, type, ptr); \
81
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
82
82
  \
83
83
  oldproc = ptr->handler; \
84
84
  rb_scan_args(argc, argv, "0&", &ptr->handler); \
@@ -90,7 +90,7 @@
90
90
  type *ptr; \
91
91
  VALUE oldproc, newproc; \
92
92
  \
93
- Data_Get_Struct(self, type, ptr); \
93
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
94
94
  \
95
95
  oldproc = rb_hash_aref(ptr->opts, rb_easy_hkey(#handler)); \
96
96
  rb_scan_args(argc, argv, "0&", &newproc); \
@@ -103,7 +103,7 @@
103
103
  #define CURB_IMMED_SETTER(type, attr, nilval) \
104
104
  type *ptr; \
105
105
  \
106
- Data_Get_Struct(self, type, ptr); \
106
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
107
107
  if (attr == Qnil) { \
108
108
  ptr->attr = nilval; \
109
109
  } else { \
@@ -116,7 +116,7 @@
116
116
  #define CURB_IMMED_GETTER(type, attr, nilval) \
117
117
  type *ptr; \
118
118
  \
119
- Data_Get_Struct(self, type, ptr); \
119
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
120
120
  if (ptr->attr == nilval) { \
121
121
  return Qnil; \
122
122
  } else { \
@@ -127,7 +127,7 @@
127
127
  #define CURB_IMMED_PORT_SETTER(type, attr, msg) \
128
128
  type *ptr; \
129
129
  \
130
- Data_Get_Struct(self, type, ptr); \
130
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
131
131
  if (attr == Qnil) { \
132
132
  ptr->attr = 0; \
133
133
  } else { \
@@ -146,7 +146,7 @@
146
146
  #define CURB_IMMED_PORT_GETTER(type, attr) \
147
147
  type *ptr; \
148
148
  \
149
- Data_Get_Struct(self, type, ptr); \
149
+ TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
150
150
  if (ptr->attr == 0) { \
151
151
  return Qnil; \
152
152
  } else { \