proxygen
proxygen::ZlibServerFilterFactory Class Reference

#include <ZlibServerFilter.h>

Inheritance diagram for proxygen::ZlibServerFilterFactory:
proxygen::RequestHandlerFactory

Public Member Functions

 ZlibServerFilterFactory (int32_t compressionLevel, uint32_t minimumCompressionSize, const std::set< std::string > compressibleContentTypes)
 
void onServerStart (folly::EventBase *) noexceptoverride
 
void onServerStop () noexceptoverride
 
RequestHandleronRequest (RequestHandler *h, HTTPMessage *msg) noexceptoverride
 
- Public Member Functions inherited from proxygen::RequestHandlerFactory
virtual ~RequestHandlerFactory ()
 

Protected Member Functions

bool acceptsSupportedCompressionType (HTTPMessage *msg) noexcept
 

Protected Attributes

int32_t compressionLevel_
 
uint32_t minimumCompressionSize_
 
const std::shared_ptr< std::set< std::string > > compressibleContentTypes_
 

Detailed Description

Definition at line 196 of file ZlibServerFilter.h.

Constructor & Destructor Documentation

proxygen::ZlibServerFilterFactory::ZlibServerFilterFactory ( int32_t  compressionLevel,
uint32_t  minimumCompressionSize,
const std::set< std::string compressibleContentTypes 
)
inlineexplicit

Definition at line 198 of file ZlibServerFilter.h.

202  : compressionLevel_(compressionLevel),
203  minimumCompressionSize_(minimumCompressionSize),
205  std::make_shared<std::set<std::string>>(compressibleContentTypes)) {
206  }
const std::shared_ptr< std::set< std::string > > compressibleContentTypes_

Member Function Documentation

bool proxygen::ZlibServerFilterFactory::acceptsSupportedCompressionType ( HTTPMessage msg)
inlineprotectednoexcept

Definition at line 231 of file ZlibServerFilter.h.

References proxygen::HTTP_HEADER_ACCEPT_ENCODING, gmock_output_test::output, and proxygen::RFC2616::parseQvalues().

231  {
232 
233  std::vector<RFC2616::TokenQPair> output;
234 
235  //Accept encoding header could have qvalues (gzip; q=5.0)
236  auto acceptEncodingHeader =
237  msg->getHeaders().getSingleOrEmpty(HTTP_HEADER_ACCEPT_ENCODING);
238 
239  if (RFC2616::parseQvalues(acceptEncodingHeader, output)) {
240  std::vector<RFC2616::TokenQPair>::iterator it = std::find_if(
241  output.begin(), output.end(), [](RFC2616::TokenQPair elem) {
242  return elem.first.compare(folly::StringPiece("gzip")) == 0;
243  });
244 
245  return (it != output.end());
246  }
247 
248  return false;
249  }
std::pair< folly::StringPiece, double > TokenQPair
Definition: RFC2616.h:69
bool parseQvalues(folly::StringPiece value, std::vector< TokenQPair > &output)
Definition: RFC2616.cpp:64
RequestHandler* proxygen::ZlibServerFilterFactory::onRequest ( RequestHandler ,
HTTPMessage  
)
inlineoverridevirtualnoexcept

Invoked for each new request server handles. HTTPMessage is provided so that user can potentially choose among several implementation of handler based on URL or something. No need to save/copy this HTTPMessage. RequestHandler will be given the HTTPMessage in a separate callback.

Some request handlers don't handle the request themselves (think filters). They do take some actions based on request/response but otherwise they just hand-off request to some other RequestHandler. This upstream RequestHandler is given as first parameter. For the terminal RequestHandler this will by nullptr.

Implements proxygen::RequestHandlerFactory.

Definition at line 212 of file ZlibServerFilter.h.

References proxygen::ZlibServerFilter::compressibleContentTypes_, proxygen::ZlibServerFilter::compressionLevel_, h, proxygen::ZlibServerFilter::minimumCompressionSize_, and proxygen::ZlibServerFilter::ZlibServerFilter().

213  {
214 
216  auto zlibServerFilter =
217  new ZlibServerFilter(h,
221  return zlibServerFilter;
222  }
223 
224  // No compression
225  return h;
226  }
*than *hazptr_holder h
Definition: Hazptr.h:116
const std::shared_ptr< std::set< std::string > > compressibleContentTypes_
bool acceptsSupportedCompressionType(HTTPMessage *msg) noexcept
void proxygen::ZlibServerFilterFactory::onServerStart ( folly::EventBase evb)
inlineoverridevirtualnoexcept

Invoked in each thread server is going to handle requests before we start handling requests. Can be used to setup thread-local setup for each thread (stats and such).

Implements proxygen::RequestHandlerFactory.

Definition at line 208 of file ZlibServerFilter.h.

208 {}
void proxygen::ZlibServerFilterFactory::onServerStop ( )
inlineoverridevirtualnoexcept

Invoked in each handler thread after all the connections are drained from that thread. Can be used to tear down thread-local setup.

Implements proxygen::RequestHandlerFactory.

Definition at line 210 of file ZlibServerFilter.h.

210 {}

Member Data Documentation

const std::shared_ptr<std::set<std::string> > proxygen::ZlibServerFilterFactory::compressibleContentTypes_
protected

Definition at line 253 of file ZlibServerFilter.h.

int32_t proxygen::ZlibServerFilterFactory::compressionLevel_
protected

Definition at line 251 of file ZlibServerFilter.h.

uint32_t proxygen::ZlibServerFilterFactory::minimumCompressionSize_
protected

Definition at line 252 of file ZlibServerFilter.h.


The documentation for this class was generated from the following file: