Class: Raptor::HttpParser

Inherits:
Object
  • Object
show all
Defined in:
ext/raptor_http/raptor_http.c

Instance Method Summary collapse

Instance Method Details

#bodyObject



1281
1282
1283
1284
1285
# File 'ext/raptor_http/raptor_http.c', line 1281

static VALUE parser_body(VALUE self) {
  raptor_parser *parser;
  TypedData_Get_Struct(self, raptor_parser, &parser_type, parser);
  return parser->body;
}

#content_lengthObject



1262
1263
1264
1265
1266
# File 'ext/raptor_http/raptor_http.c', line 1262

static VALUE parser_content_length(VALUE self) {
  raptor_parser *parser;
  TypedData_Get_Struct(self, raptor_parser, &parser_type, parser);
  return SIZET2NUM(raptor_parser_content_length(parser));
}

#execute(req_hash, buffer, start) ⇒ Object



1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
# File 'ext/raptor_http/raptor_http.c', line 1231

static VALUE parser_execute(VALUE self, VALUE req_hash, VALUE buffer, VALUE start) {
  raptor_parser *parser;
  TypedData_Get_Struct(self, raptor_parser, &parser_type, parser);

  Check_Type(buffer, T_STRING);
  parser->request = req_hash;

  size_t from = NUM2SIZET(start);
  const char *data = RSTRING_PTR(buffer);
  size_t len = RSTRING_LEN(buffer);

  if (from >= len)
    rb_raise(eHttpParserError, "start is after buffer end");

  raptor_parser_execute(parser, data + from, len - from);

  return SIZET2NUM(parser->nread);
}

#finished?Boolean

Returns:

  • (Boolean)


1250
1251
1252
1253
1254
# File 'ext/raptor_http/raptor_http.c', line 1250

static VALUE parser_finished_p(VALUE self) {
  raptor_parser *parser;
  TypedData_Get_Struct(self, raptor_parser, &parser_type, parser);
  return raptor_parser_finished(parser) ? Qtrue : Qfalse;
}

#has_body?Boolean

Returns:

  • (Boolean)


1256
1257
1258
1259
1260
# File 'ext/raptor_http/raptor_http.c', line 1256

static VALUE parser_has_body_p(VALUE self) {
  raptor_parser *parser;
  TypedData_Get_Struct(self, raptor_parser, &parser_type, parser);
  return raptor_parser_has_body(parser) ? Qtrue : Qfalse;
}

#nreadObject



1268
1269
1270
1271
1272
# File 'ext/raptor_http/raptor_http.c', line 1268

static VALUE parser_nread(VALUE self) {
  raptor_parser *parser;
  TypedData_Get_Struct(self, raptor_parser, &parser_type, parser);
  return SIZET2NUM(parser->nread);
}

#resetObject



1274
1275
1276
1277
1278
1279
# File 'ext/raptor_http/raptor_http.c', line 1274

static VALUE parser_reset(VALUE self) {
  raptor_parser *parser;
  TypedData_Get_Struct(self, raptor_parser, &parser_type, parser);
  raptor_parser_init(parser);
  return Qnil;
}