int Hpack_index_table::hpack_encode(unsigned char* buf, const char* Name, const char* value) { if(!hpack_inited) init_hpack(); unsigned char *buf_begin = buf; std::string name; while(*Name) { name += tolower(*Name++); } uint32_t index = getid(name, value); if(index){ *buf = 0x80; buf += integer_encode(buf, 7, index); }else if((index = getid(name))) { *buf = 0x40; buf += integer_encode(buf, 6, index); buf += literal_encode(buf, value); add_dynamic_table(name, value); }else { *buf = 0x40; buf++; buf += literal_encode(buf, name); buf += literal_encode(buf, value); add_dynamic_table(name, value); } return buf - buf_begin; }
int _cdk_filter_literal( void * opaque, int ctl, FILE * in, FILE * out ) { if( ctl == STREAMCTL_READ ) return literal_decode( opaque, in, out ); else if( ctl == STREAMCTL_WRITE ) return literal_encode( opaque, in, out ); else if( ctl == STREAMCTL_FREE ) { literal_filter_t * pfx = opaque; if( pfx ) { cdk_free( pfx->filename ); pfx->filename = NULL; } } return CDK_Inv_Mode; }
int _cdk_filter_literal (void *data, int ctl, FILE * in, FILE * out) { if (ctl == STREAMCTL_READ) return literal_decode (data, in, out); else if (ctl == STREAMCTL_WRITE) return literal_encode (data, in, out); else if (ctl == STREAMCTL_FREE) { literal_filter_t *pfx = data; if (pfx) { _cdk_log_debug ("free literal filter\n"); cdk_free (pfx->filename); pfx->filename = NULL; cdk_free (pfx->orig_filename); pfx->orig_filename = NULL; return 0; } } return CDK_Inv_Mode; }