Class: Agoo::Request
- Inherits:
-
Object
- Object
- Agoo::Request
- Defined in:
- ext/agoo/request.c,
ext/agoo/request.c,
ext/agoo/request.c
Overview
A representation of an HTTP request that is used with a handler that responds to the on_request method. The request is a more efficient encapsulation of the rack environment.
Instance Method Summary collapse
-
#body ⇒ Object
call-seq: body().
-
#env ⇒ Object
call-seq: to_h().
-
#environment ⇒ Object
call-seq: to_h().
-
#headers ⇒ Object
call-seq: headers().
-
#path_info ⇒ Object
call-seq: path_info().
-
#query_string ⇒ Object
call-seq: query_string().
-
#rack_errors ⇒ Object
call-seq: rack_errors().
-
#rack_input ⇒ Object
call-seq: rack_input().
-
#rack_logger ⇒ Object
call-seq: rack_logger().
-
#rack_multiprocess ⇒ Object
call-seq: rack_multiprocess().
-
#rack_multithread ⇒ Object
call-seq: rack_multithread().
-
#rack_run_once ⇒ Object
call-seq: rack_run_once().
-
#rack_url_scheme ⇒ Object
call-seq: rack_url_scheme().
-
#rack_version ⇒ Object
call-seq: rack_version().
-
#request_method ⇒ Object
call-seq: request_method().
-
#script_name ⇒ Object
call-seq: script_name().
-
#server_name ⇒ Object
call-seq: server_name().
-
#server_port ⇒ Object
call-seq: server_port().
-
#to_h ⇒ Object
call-seq: to_h().
-
#to_s ⇒ Object
call-seq: to_s().
Instance Method Details
#body ⇒ Object
call-seq: body()
Returns the body of the request as a String. If there is no body then nil is returned.
426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'ext/agoo/request.c', line 426
static VALUE
body(VALUE self) {
Req r = DATA_PTR(self);
if (NULL == r) {
rb_raise(rb_eArgError, "Request is no longer valid.");
}
if (NULL == r->body.start) {
return Qnil;
}
return rb_str_new(r->body.start, r->body.len);
}
|
#env ⇒ Object
call-seq: to_h()
Returns a Hash representation of the request which is the same as a rack environment Hash.
497 498 499 500 501 502 503 504 505 |
# File 'ext/agoo/request.c', line 497
static VALUE
to_h(VALUE self) {
Req r = DATA_PTR(self);
if (NULL == r) {
rb_raise(rb_eArgError, "Request is no longer valid.");
}
return request_env(r);
}
|
#environment ⇒ Object
call-seq: to_h()
Returns a Hash representation of the request which is the same as a rack environment Hash.
497 498 499 500 501 502 503 504 505 |
# File 'ext/agoo/request.c', line 497
static VALUE
to_h(VALUE self) {
Req r = DATA_PTR(self);
if (NULL == r) {
rb_raise(rb_eArgError, "Request is no longer valid.");
}
return request_env(r);
}
|
#headers ⇒ Object
call-seq: headers()
Returns the header of the request as a Hash.
405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'ext/agoo/request.c', line 405
static VALUE
headers(VALUE self) {
Req r = DATA_PTR(self);
volatile VALUE h;
if (NULL == r) {
rb_raise(rb_eArgError, "Request is no longer valid.");
}
h = rb_hash_new();
fill_headers(r, h);
return h;
}
|
#path_info ⇒ Object
call-seq: path_info()
Returns the script name which is assumed to be either ‘/’ or the empty according to the rack restrictions are followed on what the script name and path info should be.
125 126 127 128 |
# File 'ext/agoo/request.c', line 125
static VALUE
path_info(VALUE self) {
return req_path_info((Req)DATA_PTR(self));
}
|
#query_string ⇒ Object
call-seq: query_string()
Returns the query string of the request.
147 148 149 150 |
# File 'ext/agoo/request.c', line 147
static VALUE
query_string(VALUE self) {
return req_query_string((Req)DATA_PTR(self));
}
|
#rack_errors ⇒ Object
call-seq: rack_errors()
Returns an error stream for the request. This stream is used to write error log entries.
283 284 285 286 |
# File 'ext/agoo/request.c', line 283
static VALUE
rack_errors(VALUE self) {
return req_rack_errors((Req)DATA_PTR(self));
}
|
#rack_input ⇒ Object
call-seq: rack_input()
Returns an input stream for the request body. If no body is present then nil is returned.
266 267 268 269 |
# File 'ext/agoo/request.c', line 266
static VALUE
rack_input(VALUE self) {
return req_rack_input((Req)DATA_PTR(self));
}
|
#rack_logger ⇒ Object
call-seq: rack_logger()
Returns a RackLogger that can be used to log messages with the server logger. The methods supported are debug(), info(), warn(), error(), and fatal(). The signature is the same as the standard Ruby Logger of info(message, &block).
453 454 455 456 |
# File 'ext/agoo/request.c', line 453
static VALUE
rack_logger(VALUE self) {
return req_rack_logger((Req)DATA_PTR(self));
}
|
#rack_multiprocess ⇒ Object
call-seq: rack_multiprocess()
Returns false since the server is a single process.
316 317 318 319 |
# File 'ext/agoo/request.c', line 316 static VALUE rack_multiprocess(VALUE self) { return Qfalse; } |
#rack_multithread ⇒ Object
call-seq: rack_multithread()
Returns true is the server is using multiple handler worker threads.
305 306 307 308 |
# File 'ext/agoo/request.c', line 305
static VALUE
rack_multithread(VALUE self) {
return req_rack_multithread((Req)DATA_PTR(self));
}
|
#rack_run_once ⇒ Object
call-seq: rack_run_once()
Returns false.
327 328 329 330 |
# File 'ext/agoo/request.c', line 327 static VALUE rack_run_once(VALUE self) { return Qfalse; } |
#rack_url_scheme ⇒ Object
call-seq: rack_url_scheme()
Returns the URL scheme or either http or https as a string.
243 244 245 246 |
# File 'ext/agoo/request.c', line 243
static VALUE
rack_url_scheme(VALUE self) {
return req_rack_url_scheme((Req)DATA_PTR(self));
}
|
#rack_version ⇒ Object
call-seq: rack_version()
Returns the rack version the request is compliant with.
226 227 228 229 |
# File 'ext/agoo/request.c', line 226 static VALUE rack_version(VALUE self) { return rack_version_val_val; } |
#request_method ⇒ Object
call-seq: request_method()
Returns the HTTP method of the request.
73 74 75 76 |
# File 'ext/agoo/request.c', line 73
static VALUE
method(VALUE self) {
return req_method((Req)DATA_PTR(self));
}
|
#script_name ⇒ Object
call-seq: script_name()
Returns the path info which is assumed to be the full path unless the root and then the rack restrictions are followed on what the script name and path info should be.
101 102 103 104 |
# File 'ext/agoo/request.c', line 101
static VALUE
script_name(VALUE self) {
return req_script_name((Req)DATA_PTR(self));
}
|
#server_name ⇒ Object
call-seq: server_name()
Returns the server or host name.
181 182 183 184 |
# File 'ext/agoo/request.c', line 181
static VALUE
server_name(VALUE self) {
return req_server_name((Req)DATA_PTR(self));
}
|
#server_port ⇒ Object
call-seq: server_port()
Returns the server or host port as a string.
215 216 217 218 |
# File 'ext/agoo/request.c', line 215
static VALUE
server_port(VALUE self) {
return req_server_port((Req)DATA_PTR(self));
}
|
#to_h ⇒ Object
call-seq: to_h()
Returns a Hash representation of the request which is the same as a rack environment Hash.
497 498 499 500 501 502 503 504 505 |
# File 'ext/agoo/request.c', line 497
static VALUE
to_h(VALUE self) {
Req r = DATA_PTR(self);
if (NULL == r) {
rb_raise(rb_eArgError, "Request is no longer valid.");
}
return request_env(r);
}
|
#to_s ⇒ Object
call-seq: to_s()
Returns a string representation of the request.
513 514 515 516 517 518 |
# File 'ext/agoo/request.c', line 513 static VALUE to_s(VALUE self) { volatile VALUE h = to_h(self); return rb_funcall(h, rb_intern("to_s"), 0); } |