static VALUE header_hash_tidy_key(VALUE key) { if (TYPE(key) == T_SYMBOL) { key = rb_sym_to_s(key); } else { Check_Type(key, T_STRING); key = rb_enc_str_new(RSTRING_PTR(key), RSTRING_LEN(key), u8_encoding); } nyara_headerlize(key); return key; }
static int on_header_value(http_parser* parser, const char* s, size_t len) { Request* p = (Request*)parser; if (p->last_field == Qnil) { if (p->last_value == Qnil) { p->parse_state = PS_ERROR; return 1; } rb_str_cat(p->last_value, s, len); } else { nyara_headerlize(p->last_field); p->last_value = rb_enc_str_new(s, len, u8_encoding); rb_hash_aset(p->header, p->last_field, p->last_value); p->last_field = Qnil; } return 0; }