int spdy_decompress_header_block( Byte* data, size_t data_len, unsigned char* processed, size_t* processed_len, z_stream* decomp) {
if (!decomp) {
// I should return error...
spdy_log_error("Error occurred getting decompressor!!!");
return -1;
}
char decomp_buffer[HEADER_CHUNK_MAX_SIZE];
size_t decompressed_len = 0;
int rv = -1;
inflateReset(decomp);
decomp->next_in = data;
decomp->avail_in = data_len;
while (decomp->avail_in > 0) {
decomp->next_out = (Byte*)decomp_buffer;
decomp->avail_out = HEADER_CHUNK_MAX_SIZE;
rv = inflate(decomp,Z_SYNC_FLUSH);
if (rv == Z_NEED_DICT) {
uLong dictionary_id = calculate_dictionary_id((Byte*)SPDY_dictionary, sizeof(SPDY_dictionary));
if (decomp->adler == dictionary_id){
rv = inflateSetDictionary(decomp, (Byte*)SPDY_dictionary, sizeof(SPDY_dictionary));
rv = inflate(decomp, Z_SYNC_FLUSH);
}
}
if ((rv == Z_OK) || ((rv == Z_BUF_ERROR) && (decomp->avail_in == 0))) {
decompressed_len = HEADER_CHUNK_MAX_SIZE - decomp->avail_out;
if (decompressed_len > 0) {
memcpy(processed + *processed_len, decomp_buffer, decompressed_len);
*processed_len += decompressed_len;
}
} else {
if(rv == Z_DATA_ERROR){
spdy_log_error("Error inflating headers: Z_DATA_ERROR encountered" );
}else{
spdy_log_error("Error inflating headers!!!");
}
return -1;
}
}
return *processed_len;
2013/03/19 1:18 "Ramon RiseRide Orrù" <gordonf...@gmail.com>:
>
> I'm developing my own implementation of SPDY support for a web server written in C, when i decompress header blocks, i can decompress block from first frame without problems, calling inflate on second frame block returns a Z_DATA_ERROR (-3) code. I'm using this function:
>
Spdy uses endless zlib stream per connection, not per stream. Try decompress incoming header block without re-initialize zlib context.
Best regards,
Tatsuhiro Tsujikawa
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "spdy-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to spdy-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>