예제 #1
0
// caveats:
// - stops at '='
// - matrix uri params and query are ignored
static VALUE ext_unescape(VALUE _, volatile VALUE s, VALUE v_is_path) {
  Check_Type(s, T_STRING);
  if (RTEST(v_is_path)) {
    volatile VALUE output = _new_blank_str();
    if (nyara_parse_path(output, RSTRING_PTR(s), RSTRING_LEN(s))) {
    }
    return output;
  } else {
    volatile VALUE output = _new_blank_str();
    _decode_url_seg(output, RSTRING_PTR(s), RSTRING_LEN(s), '=');
    return output;
  }
}
예제 #2
0
// may override POST by _method in query
static void _parse_path_and_query(Request* p) {
  char* s = RSTRING_PTR(p->path_with_query);
  long len = RSTRING_LEN(p->path_with_query);
  long query_i = nyara_parse_path(p->path, s, len);
  if (query_i < len) {
    nyara_parse_param(p->query, s + query_i, len - query_i);

    // do method override with _method=xxx in query
    if (p->method == HTTP_POST) {
      VALUE meth = rb_hash_aref(p->query, method_override_key);
      if (TYPE(meth) == T_STRING) {
        _upcase_method(meth);
        VALUE meth_num = rb_hash_aref(nyara_http_methods, meth);
        if (meth_num != Qnil) {
          p->method = FIX2INT(meth_num);
        }
      }
    }
  }
}
예제 #3
0
// concats result into output<br>
// returns parsed length
static VALUE ext_parse_path(VALUE self, VALUE output, VALUE input) {
  long parsed = nyara_parse_path(output, RSTRING_PTR(input), RSTRING_LEN(input));
  return ULONG2NUM(parsed);
}