sfml3.rb

Class: SFML::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
ext/network/http.c,
ext/network/http.c

Overview

The status, headers and body returned by Http#send_request.

Instance Method Summary collapse

Instance Method Details

#body ⇒ String

Returns the body of the response.

Returns:

  • (String)

Returns:

  • (String) —

    the body of the response, possibly an error message when the server sent something other than valid HTML



308
309
310
# File 'ext/network/http.c', line 308

static VALUE HttpResponse_body(VALUE self) {
    return rb_str_new_cstr(sfHttpResponse_getBody(Get_HttpResponse_Struct(self)));
}

#field(name) ⇒ String?

Returns the value of the response header field named name.

Returns:

  • (String, nil)

Returns:

  • (String, nil) —

    the value of response header field name (case-insensitive), or nil if it wasn't sent



253
254
255
256
257
258
# File 'ext/network/http.c', line 253

static VALUE HttpResponse_field(VALUE self, VALUE rb_field) {
    const char* field =
        sfHttpResponse_getField(Get_HttpResponse_Struct(self), StringValueCStr(rb_field));

    return field != NULL ? rb_str_new_cstr(field) : Qnil;
}

#major_version ⇒ Integer

Returns the major component of the HTTP protocol version.

Returns:

  • (Integer)

Returns:

  • (Integer) —

    the major version of the HTTP protocol used by the server



287
288
289
# File 'ext/network/http.c', line 287

static VALUE HttpResponse_major_version(VALUE self) {
    return UINT2NUM(sfHttpResponse_getMajorVersion(Get_HttpResponse_Struct(self)));
}

#minor_version ⇒ Integer

Returns the minor component of the HTTP protocol version.

Returns:

  • (Integer)

Returns:

  • (Integer) —

    the minor version of the HTTP protocol used by the server



297
298
299
# File 'ext/network/http.c', line 297

static VALUE HttpResponse_minor_version(VALUE self) {
    return UINT2NUM(sfHttpResponse_getMinorVersion(Get_HttpResponse_Struct(self)));
}

#status ⇒ Integer

Returns the numeric HTTP status code.

Returns:

  • (Integer)

Returns:

  • (Integer) —

    the raw HTTP status code



266
267
268
# File 'ext/network/http.c', line 266

static VALUE HttpResponse_status(VALUE self) {
    return INT2NUM(sfHttpResponse_getStatus(Get_HttpResponse_Struct(self)));
}

#status_name ⇒ Symbol

Returns the status as an HttpStatus name.

Returns:

  • (Symbol)

Returns:

  • (Symbol) —

    an HttpStatus name for #status



276
277
278
279
# File 'ext/network/http.c', line 276

static VALUE HttpResponse_status_name(VALUE self) {
    return ID2SYM(
        rb_intern(http_status_name(sfHttpResponse_getStatus(Get_HttpResponse_Struct(self)))));
}