HTTP-Headers-Fast-XS
view release on metacpan or search on metacpan
av_push( (AV *) SvRV(*h), *a_value );
}
} else {
av_push( (AV *) SvRV(*h), val );
}
}
MODULE = HTTP::Headers::Fast::XS PACKAGE = HTTP::Headers::Fast::XS
PROTOTYPES: DISABLE
BOOT:
{
MY_CXT_INIT;
MY_CXT.standard_case = get_hv( "HTTP::Headers::Fast::standard_case", 0 );
MY_CXT.translate = hv_fetch(
gv_stashpvn( "HTTP::Headers::Fast", 19, 0 ),
"TRANSLATE_UNDERSCORE",
20,
0
);
}
char *
_standardize_field_name(SV *field)
PREINIT:
char *field_name;
STRLEN len;
CODE:
field_name = SvPV(field, len);
handle_standard_case(aTHX_ field_name, len);
RETVAL = field_name;
OUTPUT: RETVAL
void
push_header( SV *self, ... )
PREINIT:
int i;
STRLEN len;
char *field;
SV *val;
CODE:
if ( items % 2 == 0 )
croak("You must provide key/value pairs");
for ( i = 1; i < items; i += 2 ) {
field = SvPV(ST(i), len);
val = newSVsv( ST( i + 1 ) );
handle_standard_case(aTHX_ field, len);
__push_header(aTHX_ (HV *) SvRV(self), field, len, val);
}
void
_header_get( SV *self, SV *field_name, ... )
PREINIT:
char *field;
STRLEN len;
bool skip_standardize;
PPCODE:
field = SvPV(field_name, len);
skip_standardize = ( items == 3 ) && SvTRUE(ST(3));
if (!skip_standardize)
handle_standard_case(aTHX_ field, len);
/* we are putting the decremented(with the number of input parameters) SP back in the THX */
PUTBACK;
put_header_value_on_perl_stack(aTHX_ self, field, len);
/* we are setting the local SP variable to the value in THX(it was changed inside the previous function call) */
SPAGAIN;
void
_header_set(SV *self, SV *field_name, SV *val)
PREINIT:
char *field;
STRLEN len;
bool found;
SV **a_value;
PPCODE:
field = SvPV(field_name, len);
handle_standard_case(aTHX_ field, len);
/* we are putting the decremented(with the number of input parameters) SP back in the THX */
PUTBACK;
found = put_header_value_on_perl_stack(aTHX_ self, field, len);
/* we are setting the local SP variable to the value in THX */
SPAGAIN;
if (!SvOK(val) && found) {
hv_delete((HV *) SvRV(self), field, len, G_DISCARD);
} else {
/* av_len == 0 here means that we have one item in av */
if ( SvROK(val) &&
SvTYPE( SvRV(val) ) == SVt_PVAV &&
av_len((AV *)SvRV(val)) == 0) {
a_value = av_fetch( (AV *)SvRV(val), 0, 0 );
val = *a_value;
}
hv_store( (HV *) SvRV(self), field, len, newSVsv(val), 0);
}
void
_header_push(SV *self, SV *field_name, SV *val)
PREINIT:
char *field;
STRLEN len;
PPCODE:
field = SvPV(field_name, len);
handle_standard_case(aTHX_ field, len);
/* we are putting the decremented (with the number of
input parameters) SP back in the THX */
PUTBACK;
put_header_value_on_perl_stack(aTHX_ self, field, len);
/* we are setting the local SP variable to the value in THX */
SPAGAIN;
__push_header(aTHX_ (HV *) SvRV(self), field, len, newSVsv(val));
( run in 0.419 second using v1.01-cache-2.11-cpan-5511b514fd6 )