Class: Raptor::HttpParser

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

Instance Method Summary collapse

Instance Method Details

#bodyObject



1289
1290
1291
1292
1293
# File 'ext/raptor_http/raptor_http.c', line 1289

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

#content_lengthObject



1270
1271
1272
1273
1274
# File 'ext/raptor_http/raptor_http.c', line 1270

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



1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
# File 'ext/raptor_http/raptor_http.c', line 1239

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)


1258
1259
1260
1261
1262
# File 'ext/raptor_http/raptor_http.c', line 1258

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)


1264
1265
1266
1267
1268
# File 'ext/raptor_http/raptor_http.c', line 1264

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



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

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

#resetObject



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

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