Method: Curl::Easy#code

Defined in:
ext/curb_easy.c

#response_codeFixnum

Retrieve the last received HTTP or FTP code. This will be zero if no server response code has been received. Note that a proxy’s CONNECT response should be read with http_connect_code and not this method.

Returns:

  • (Fixnum)


3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
# File 'ext/curb_easy.c', line 3507

static VALUE ruby_curl_easy_response_code_get(VALUE self) {
  ruby_curl_easy *rbce;
  long code;

  TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#ifdef HAVE_CURLINFO_RESPONSE_CODE
  curl_easy_getinfo(rbce->curl, CURLINFO_RESPONSE_CODE, &code);
#else
  // old libcurl
  curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CODE, &code);
#endif

  return LONG2NUM(code);
}