The simplest approach is to read zpipe.c, which has a walk-through in zlib documentation.
It is tiny and comprehensive, implements and illustrates compression and decompression. You can just copy and paste and modify the data stream stuff, for example you may not read and write to files but to memory.
One thing to notice: if you're handling GZIP (instead of deflate), which you may find when making a HTTP request, you need to replace inflateInit(&strm) with inflateInit2(&strm, 16 + MAX_WBITS), since GZIP has a bigger header.