Class: Raptor::HttpParser

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

Instance Method Summary collapse

Instance Method Details

#bodyObject



1213
1214
1215
1216
1217
# File 'ext/raptor_http/raptor_http.c', line 1213

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

#content_lengthObject



1194
1195
1196
1197
1198
# File 'ext/raptor_http/raptor_http.c', line 1194

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



1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
# File 'ext/raptor_http/raptor_http.c', line 1163

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)


1182
1183
1184
1185
1186
# File 'ext/raptor_http/raptor_http.c', line 1182

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)


1188
1189
1190
1191
1192
# File 'ext/raptor_http/raptor_http.c', line 1188

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



1200
1201
1202
1203
1204
# File 'ext/raptor_http/raptor_http.c', line 1200

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

#resetObject



1206
1207
1208
1209
1210
1211
# File 'ext/raptor_http/raptor_http.c', line 1206

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