Class: Agoo::Request

Inherits:
Object
  • Object
show all
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

Instance Method Details

#bodyObject

call-seq: body()

Returns the body of the request as a String. If there is no body then nil is returned.



511
512
513
514
515
516
517
518
519
520
521
522
# File 'ext/agoo/request.c', line 511

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);
}

#envObject

call-seq: to_h()

Returns a Hash representation of the request which is the same as a rack environment Hash.



586
587
588
589
590
591
592
593
594
# File 'ext/agoo/request.c', line 586

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);
}

#environmentObject

call-seq: to_h()

Returns a Hash representation of the request which is the same as a rack environment Hash.



586
587
588
589
590
591
592
593
594
# File 'ext/agoo/request.c', line 586

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);
}

#headersObject

call-seq: headers()

Returns the header of the request as a Hash.



490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'ext/agoo/request.c', line 490

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_infoObject

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.



153
154
155
156
# File 'ext/agoo/request.c', line 153

static VALUE
path_info(VALUE self) {
    return req_path_info((Req)DATA_PTR(self));
}

#query_stringObject

call-seq: query_string()

Returns the query string of the request.



175
176
177
178
# File 'ext/agoo/request.c', line 175

static VALUE
query_string(VALUE self) {
    return req_query_string((Req)DATA_PTR(self));
}

#rack_errorsObject

call-seq: rack_errors()

Returns an error stream for the request. This stream is used to write error log entries.



331
332
333
334
# File 'ext/agoo/request.c', line 331

static VALUE
rack_errors(VALUE self) {
    return req_rack_errors((Req)DATA_PTR(self));
}

#rack_inputObject

call-seq: rack_input()

Returns an input stream for the request body. If no body is present then nil is returned.



314
315
316
317
# File 'ext/agoo/request.c', line 314

static VALUE
rack_input(VALUE self) {
    return req_rack_input((Req)DATA_PTR(self));
}

#rack_loggerObject

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).



538
539
540
541
# File 'ext/agoo/request.c', line 538

static VALUE
rack_logger(VALUE self) {
    return req_rack_logger((Req)DATA_PTR(self));
}

#rack_multiprocessObject

call-seq: rack_multiprocess()

Returns false since the server is a single process.



364
365
366
367
# File 'ext/agoo/request.c', line 364

static VALUE
rack_multiprocess(VALUE self) {
    return Qfalse;
}

#rack_multithreadObject

call-seq: rack_multithread()

Returns true is the server is using multiple handler worker threads.



353
354
355
356
# File 'ext/agoo/request.c', line 353

static VALUE
rack_multithread(VALUE self) {
    return req_rack_multithread((Req)DATA_PTR(self));
}

#rack_run_onceObject

call-seq: rack_run_once()

Returns false.



375
376
377
378
# File 'ext/agoo/request.c', line 375

static VALUE
rack_run_once(VALUE self) {
    return Qfalse;
}

#rack_upgrade?Boolean

call-seq: rack_upgrade?()

Returns the URL scheme or either http or https as a string.

Returns:

  • (Boolean)


263
264
265
266
# File 'ext/agoo/request.c', line 263

static VALUE
rack_upgrade(VALUE self) {
    return req_rack_upgrade((Req)DATA_PTR(self));
}

#rack_url_schemeObject

call-seq: rack_url_scheme()

Returns the URL scheme or either http or https as a string.



291
292
293
294
# File 'ext/agoo/request.c', line 291

static VALUE
rack_url_scheme(VALUE self) {
    return req_rack_url_scheme((Req)DATA_PTR(self));
}

#rack_versionObject

call-seq: rack_version()

Returns the rack version the request is compliant with.



274
275
276
277
# File 'ext/agoo/request.c', line 274

static VALUE
rack_version(VALUE self) {
    return rack_version_val_val;
}

#request_methodObject

call-seq: request_method()

Returns the HTTP method of the request.



100
101
102
103
# File 'ext/agoo/request.c', line 100

static VALUE
method(VALUE self) {
    return req_method((Req)DATA_PTR(self));
}

#script_nameObject

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.



125
126
127
128
# File 'ext/agoo/request.c', line 125

static VALUE
script_name(VALUE self) {
    return req_script_name((Req)DATA_PTR(self));
}

#server_nameObject

call-seq: server_name()

Returns the server or host name.



209
210
211
212
# File 'ext/agoo/request.c', line 209

static VALUE
server_name(VALUE self) {
    return req_server_name((Req)DATA_PTR(self));
}

#server_portObject

call-seq: server_port()

Returns the server or host port as a string.



243
244
245
246
# File 'ext/agoo/request.c', line 243

static VALUE
server_port(VALUE self) {
    return req_server_port((Req)DATA_PTR(self));
}

#to_hObject

call-seq: to_h()

Returns a Hash representation of the request which is the same as a rack environment Hash.



586
587
588
589
590
591
592
593
594
# File 'ext/agoo/request.c', line 586

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_sObject

call-seq: to_s()

Returns a string representation of the request.



602
603
604
605
606
607
# File 'ext/agoo/request.c', line 602

static VALUE
to_s(VALUE self) {
    volatile VALUE	h = to_h(self);

    return rb_funcall(h, rb_intern("to_s"), 0);
}