Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ext/curb.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ void Init_curb_core() {
#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
CURB_DEFINE(CURL_HTTP_VERSION_2_0);
#endif
#if LIBCURL_VERSION_NUM >= 0x072f00 /* 7.47.0 */
CURB_DEFINE(CURL_HTTP_VERSION_2TLS);
#endif
#if HAVE_CURLOPT_IGNORE_CONTENT_LENGTH
CURB_DEFINE(CURLOPT_IGNORE_CONTENT_LENGTH);
#endif
Expand Down Expand Up @@ -1023,6 +1026,10 @@ void Init_curb_core() {
CURB_DEFINE(CURLOPT_UNIX_SOCKET_PATH);
#endif

#if HAVE_CURLOPT_PIPEWAIT
CURB_DEFINE(CURLOPT_PIPEWAIT);
#endif

#if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
CURB_DEFINE(CURLPIPE_NOTHING);
CURB_DEFINE(CURLPIPE_HTTP1);
Expand Down
13 changes: 13 additions & 0 deletions ext/curb_easy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,9 @@ static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
case CURLOPT_NOSIGNAL:
#if HAVE_CURLOPT_PATH_AS_IS
case CURLOPT_PATH_AS_IS:
#endif
#if HAVE_CURLOPT_PIPEWAIT
case CURLOPT_PIPEWAIT:
#endif
case CURLOPT_HTTPGET:
case CURLOPT_NOBODY: {
Expand Down Expand Up @@ -3359,6 +3362,16 @@ static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
case CURLOPT_UNIX_SOCKET_PATH: {
curl_easy_setopt(rbce->curl, CURLOPT_UNIX_SOCKET_PATH, StringValueCStr(val));
} break;
#endif
#if HAVE_CURLOPT_MAX_SEND_SPEED_LARGE
case CURLOPT_MAX_SEND_SPEED_LARGE: {
curl_easy_setopt(rbce->curl, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t) NUM2LL(val));
} break;
#endif
#if HAVE_CURLOPT_MAX_RECV_SPEED_LARGE
case CURLOPT_MAX_RECV_SPEED_LARGE: {
curl_easy_setopt(rbce->curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t) NUM2LL(val));
} break;
#endif
default:
rb_raise(rb_eTypeError, "Curb unsupported option");
Expand Down
79 changes: 79 additions & 0 deletions ext/curb_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ VALUE eCurlErrFileError;
VALUE eCurlErrLDAPError;
VALUE eCurlErrTelnetError;
VALUE eCurlErrTFTPError;
VALUE eCurlErrRTSPError;

/* Specific libcurl errors */
VALUE eCurlErrOK; /* not really an error but a return code */
Expand Down Expand Up @@ -127,6 +128,18 @@ VALUE mCurlErrUnknownOption;
VALUE eCurlErrInvalidPostField;


/* new errors */
VALUE eCurlErrFTPPRETFailed;
VALUE eCurlErrRTSPCseqError;
VALUE eCurlErrRTSPSessionError;
VALUE eCurlErrFTPBadFileList;
VALUE eCurlErrChunkFailed;
VALUE eCurlErrNoConnectionAvailable;
VALUE eCurlErrSSLPinnedPubKeyNotMatch;
VALUE eCurlErrSSLInvalidCertStatus;
VALUE eCurlErrHTTP2Stream;


VALUE rb_curl_easy_error(CURLcode code) {
VALUE exclz;
const char *exmsg = NULL;
Expand Down Expand Up @@ -445,6 +458,61 @@ VALUE rb_curl_easy_error(CURLcode code) {
exclz = eCurlErrSSLIssuerError;
break;
#endif

#ifdef HAVE_CURLE_FTP_PRET_FAILED
case CURLE_FTP_PRET_FAILED: /* 84 */
exclz = eCurlErrFTPPRETFailed;
break;
#endif

#ifdef HAVE_CURLE_RTSP_CSEQ_ERROR
case CURLE_RTSP_CSEQ_ERROR: /* 85 */
exclz = eCurlErrRTSPCseqError;
break;
#endif

#ifdef HAVE_CURLE_RTSP_SESSION_ERROR
case CURLE_RTSP_SESSION_ERROR: /* 86 */
exclz = eCurlErrRTSPSessionError;
break;
#endif

#ifdef HAVE_CURLE_FTP_BAD_FILE_LIST
case CURLE_FTP_BAD_FILE_LIST: /* 87 */
exclz = eCurlErrFTPBadFileList;
break;
#endif

#ifdef HAVE_CURLE_CHUNK_FAILED
case CURLE_CHUNK_FAILED: /* 88 */
exclz = eCurlErrChunkFailed;
break;
#endif

#ifdef HAVE_CURLE_NO_CONNECTION_AVAILABLE
case CURLE_NO_CONNECTION_AVAILABLE: /* 89 */
exclz = eCurlErrNoConnectionAvailable;
break;
#endif

#ifdef HAVE_CURLE_SSL_PINNEDPUBKEYNOTMATCH
case CURLE_SSL_PINNEDPUBKEYNOTMATCH: /* 90 */
exclz = eCurlErrSSLPinnedPubKeyNotMatch;
break;
#endif

#ifdef HAVE_CURLE_SSL_INVALIDCERTSTATUS
case CURLE_SSL_INVALIDCERTSTATUS: /* 91 */
exclz = eCurlErrSSLInvalidCertStatus;
break;
#endif

#ifdef HAVE_CURLE_HTTP2_STREAM
case CURLE_HTTP2_STREAM: /* 92 */
exclz = eCurlErrHTTP2Stream;
break;
#endif

default:
exclz = eCurlErrError;
exmsg = "Unknown error result from libcurl";
Expand Down Expand Up @@ -532,6 +600,7 @@ void init_curb_errors() {
eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
eCurlErrRTSPError = rb_define_class_under(mCurlErr, "RTSPError", eCurlErrError);

eCurlErrOK = rb_define_class_under(mCurlErr, "CurlOK", eCurlErrError);
eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
Expand Down Expand Up @@ -657,4 +726,14 @@ void init_curb_errors() {
eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);

eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);

eCurlErrFTPPRETFailed = rb_define_class_under(mCurlErr, "PPRETFailedError", eCurlErrFTPError);
eCurlErrRTSPCseqError = rb_define_class_under(mCurlErr, "CseqError", eCurlErrRTSPError);
eCurlErrRTSPSessionError = rb_define_class_under(mCurlErr, "SessionError", eCurlErrRTSPError);
eCurlErrFTPBadFileList = rb_define_class_under(mCurlErr, "BadFileListError", eCurlErrFTPError);
eCurlErrChunkFailed = rb_define_class_under(mCurlErr, "ChunkFailedError", eCurlErrError);
eCurlErrNoConnectionAvailable = rb_define_class_under(mCurlErr, "NoConnectionAvailableError", eCurlErrError);
eCurlErrSSLPinnedPubKeyNotMatch = rb_define_class_under(mCurlErr, "SSLPinnedPubKeyNotMatchError", eCurlErrError);
eCurlErrSSLInvalidCertStatus = rb_define_class_under(mCurlErr, "SSLInvalidCertStatusError", eCurlErrError);
eCurlErrHTTP2Stream = rb_define_class_under(mCurlErr, "HTTP2StreamError", eCurlErrHTTPError);
}
13 changes: 13 additions & 0 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,16 @@ def have_constant(name)

have_constant "curle_obsolete" # removed in 7.24 ?

have_constant "curle_ftp_pret_failed"
have_constant "curle_rtsp_cseq_error"
have_constant "curle_rtsp_session_error"
have_constant "curle_ftp_bad_file_list"
have_constant "curle_chunk_failed"
have_constant "curle_no_connection_available"
have_constant "curle_ssl_pinnedpubkeynotmatch"
have_constant "curle_ssl_invalidcertstatus"
have_constant "curle_http2_stream"

# gssapi/spnego delegation related constants
have_constant "curlopt_gssapi_delegation"
have_constant "curlgssapi_delegation_policy_flag"
Expand All @@ -377,6 +387,9 @@ def have_constant(name)
# added in 7.42.0
have_constant "curlopt_path_as_is"

# added in 7.43.0
have_constant "curlopt_pipewait"

if try_compile('int main() { return 0; }','-Wall')
$CFLAGS << ' -Wall'
end
Expand Down