proxygen
proxygen::MockHTTPHandler Class Reference

#include <HTTPSessionMocks.h>

Inheritance diagram for proxygen::MockHTTPHandler:
proxygen::HTTPHandlerBase proxygen::HTTPTransactionHandler

Public Member Functions

 MockHTTPHandler ()
 
 MockHTTPHandler (HTTPTransaction &txn, HTTPMessage *msg, const folly::SocketAddress &)
 
 GMOCK_METHOD1_ (, noexcept,, setTransaction, void(HTTPTransaction *txn))
 
 GMOCK_METHOD0_ (, noexcept,, detachTransaction, void())
 
void onHeadersComplete (std::unique_ptr< HTTPMessage > msg) noexceptoverride
 
 GMOCK_METHOD1_ (, noexcept,, onHeadersComplete, void(std::shared_ptr< HTTPMessage > msg))
 
void onBody (std::unique_ptr< folly::IOBuf > chain) noexceptoverride
 
 GMOCK_METHOD1_ (, noexcept,, onBody, void(std::shared_ptr< folly::IOBuf > chain))
 
 GMOCK_METHOD1_ (, noexcept,, onChunkHeader, void(size_t length))
 
 GMOCK_METHOD0_ (, noexcept,, onChunkComplete, void())
 
void onTrailers (std::unique_ptr< HTTPHeaders > trailers) noexceptoverride
 
 GMOCK_METHOD1_ (, noexcept,, onTrailers, void(std::shared_ptr< HTTPHeaders > trailers))
 
 GMOCK_METHOD0_ (, noexcept,, onEOM, void())
 
 GMOCK_METHOD1_ (, noexcept,, onUpgrade, void(UpgradeProtocol protocol))
 
 GMOCK_METHOD1_ (, noexcept,, onError, void(const HTTPException &error))
 
 GMOCK_METHOD1_ (, noexcept,, onGoaway, void(ErrorCode))
 
 GMOCK_METHOD0_ (, noexcept,, onEgressPaused, void())
 
 GMOCK_METHOD0_ (, noexcept,, onEgressResumed, void())
 
 GMOCK_METHOD1_ (, noexcept,, onPushedTransaction, void(HTTPTransaction *))
 
 GMOCK_METHOD1_ (, noexcept,, onExTransaction, void(HTTPTransaction *))
 
void expectTransaction (std::function< void(HTTPTransaction *txn)> callback)
 
void expectTransaction (HTTPTransaction **pTxn=nullptr)
 
void expectHeaders (std::function< void()> callback=std::function< void()>())
 
void expectHeaders (std::function< void(std::shared_ptr< HTTPMessage >)> cb)
 
void expectTrailers (std::function< void(std::shared_ptr< HTTPHeaders > trailers)> cb)
 
void expectChunkHeader (std::function< void()> callback=std::function< void()>())
 
void expectBody (std::function< void()> callback=std::function< void()>())
 
void expectBody (std::function< void(std::shared_ptr< folly::IOBuf >)> callback)
 
void expectChunkComplete (std::function< void()> callback=std::function< void()>())
 
void expectEOM (std::function< void()> callback=std::function< void()>())
 
void expectEgressPaused (std::function< void()> callback=std::function< void()>())
 
void expectEgressResumed (std::function< void()> callback=std::function< void()>())
 
void expectError (std::function< void(const HTTPException &ex)> callback=std::function< void(const HTTPException &ex)>())
 
void expectGoaway (std::function< void(ErrorCode)> callback=std::function< void(ErrorCode)>())
 
void expectDetachTransaction (std::function< void()> callback=std::function< void()>())
 
- Public Member Functions inherited from proxygen::HTTPHandlerBase
 HTTPHandlerBase ()
 
 HTTPHandlerBase (HTTPTransaction *txn, HTTPMessage *msg)
 
void terminate ()
 
void sendRequest ()
 
void sendRequest (HTTPMessage req)
 
void sendHeaders (uint32_t code, uint32_t content_length, bool keepalive=true, HeaderMap headers=HeaderMap())
 
void sendReply ()
 
void sendReplyCode (uint32_t code)
 
void sendBody (uint32_t content_length)
 
void sendBodyWithLastByteTracking (uint32_t content_length)
 
void sendReplyWithBody (uint32_t code, uint32_t content_length, bool keepalive=true, bool sendEOM=true, bool hasTrailers=false)
 
void sendEOM ()
 
void sendChunkedReplyWithBody (uint32_t code, uint32_t content_length, uint32_t chunkSize, bool hasTrailers, bool sendEOM=true)
 
- Public Member Functions inherited from proxygen::HTTPTransactionHandler
virtual void setTransaction (HTTPTransaction *txn) noexcept=0
 
virtual void detachTransaction () noexcept=0
 
virtual void onChunkHeader (size_t) noexcept
 
virtual void onChunkComplete () noexcept
 
virtual void onEOM () noexcept=0
 
virtual void onUpgrade (UpgradeProtocol protocol) noexcept=0
 
virtual void onError (const HTTPException &error) noexcept=0
 
virtual void onEgressPaused () noexcept=0
 
virtual void onEgressResumed () noexcept=0
 
virtual void onPushedTransaction (HTTPTransaction *) noexcept
 
virtual void onExTransaction (HTTPTransaction *) noexcept
 
virtual void onGoaway (ErrorCode) noexcept
 
virtual ~HTTPTransactionHandler ()
 

Additional Inherited Members

- Public Types inherited from proxygen::HTTPHandlerBase
using HeaderMap = std::map< std::string, std::string >
 
- Public Attributes inherited from proxygen::HTTPHandlerBase
HTTPTransactiontxn_ {nullptr}
 
std::shared_ptr< HTTPMessagemsg_
 

Detailed Description

Definition at line 142 of file HTTPSessionMocks.h.

Constructor & Destructor Documentation

proxygen::MockHTTPHandler::MockHTTPHandler ( )
inline

Definition at line 146 of file HTTPSessionMocks.h.

146  {
147  }
proxygen::MockHTTPHandler::MockHTTPHandler ( HTTPTransaction txn,
HTTPMessage msg,
const folly::SocketAddress  
)
inline

Definition at line 148 of file HTTPSessionMocks.h.

References GMOCK_NOEXCEPT_METHOD0, and GMOCK_NOEXCEPT_METHOD1.

151  : HTTPHandlerBase(&txn, msg) {
152  }

Member Function Documentation

void proxygen::MockHTTPHandler::expectBody ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 241 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::InvokeWithoutArgs().

Referenced by TEST_F().

241  {
242  if (callback) {
243  EXPECT_CALL(*this, onBody(testing::_))
244  .WillOnce(testing::InvokeWithoutArgs(callback));
245  } else {
246  EXPECT_CALL(*this, onBody(testing::_));
247  }
248  }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void onBody(std::unique_ptr< folly::IOBuf > chain) noexceptoverride
void proxygen::MockHTTPHandler::expectBody ( std::function< void(std::shared_ptr< folly::IOBuf >)>  callback)
inline

Definition at line 250 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::Invoke().

250  {
251  EXPECT_CALL(*this, onBody(testing::_)).WillOnce(testing::Invoke(callback));
252  }
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void onBody(std::unique_ptr< folly::IOBuf > chain) noexceptoverride
void proxygen::MockHTTPHandler::expectChunkComplete ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 254 of file HTTPSessionMocks.h.

References EXPECT_CALL, and testing::InvokeWithoutArgs().

255  {
256  if (callback) {
257  EXPECT_CALL(*this, onChunkComplete())
258  .WillOnce(testing::InvokeWithoutArgs(callback));
259  } else {
260  EXPECT_CALL(*this, onChunkComplete());
261  }
262  }
virtual void onChunkComplete() noexcept
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
void proxygen::MockHTTPHandler::expectChunkHeader ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 231 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::InvokeWithoutArgs().

232  {
233  if (callback) {
235  .WillOnce(testing::InvokeWithoutArgs(callback));
236  } else {
238  }
239  }
virtual void onChunkHeader(size_t) noexcept
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void proxygen::MockHTTPHandler::expectDetachTransaction ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 310 of file HTTPSessionMocks.h.

References EXPECT_CALL, and testing::Invoke().

Referenced by HTTPDownstreamTest< SPDY3_1CodecPair >::onEOMTerminateHandlerExpectShutdown(), and TEST_F().

311  {
312  if (callback) {
314  .WillOnce(testing::Invoke(callback));
315  } else {
316  EXPECT_CALL(*this, detachTransaction());
317  }
318  }
virtual void detachTransaction() noexcept=0
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
void proxygen::MockHTTPHandler::expectEgressPaused ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 272 of file HTTPSessionMocks.h.

References EXPECT_CALL, and testing::Invoke().

273  {
274  if (callback) {
275  EXPECT_CALL(*this, onEgressPaused()).WillOnce(testing::Invoke(callback));
276  } else {
277  EXPECT_CALL(*this, onEgressPaused());
278  }
279  }
virtual void onEgressPaused() noexcept=0
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
void proxygen::MockHTTPHandler::expectEgressResumed ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 281 of file HTTPSessionMocks.h.

References EXPECT_CALL, and testing::Invoke().

282  {
283  if (callback) {
284  EXPECT_CALL(*this, onEgressResumed()).WillOnce(testing::Invoke(callback));
285  } else {
286  EXPECT_CALL(*this, onEgressResumed());
287  }
288  }
virtual void onEgressResumed() noexcept=0
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
void proxygen::MockHTTPHandler::expectEOM ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 264 of file HTTPSessionMocks.h.

References EXPECT_CALL, and testing::Invoke().

Referenced by HTTPDownstreamTest< SPDY3_1CodecPair >::onEOMTerminateHandlerExpectShutdown(), and TEST_F().

264  {
265  if (callback) {
266  EXPECT_CALL(*this, onEOM()).WillOnce(testing::Invoke(callback));
267  } else {
268  EXPECT_CALL(*this, onEOM());
269  }
270  }
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
virtual void onEOM() noexcept=0
#define EXPECT_CALL(obj, call)
void proxygen::MockHTTPHandler::expectError ( std::function< void(const HTTPException &ex)>  callback = std::function<void(const HTTPException& ex)>())
inline

Definition at line 290 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::Invoke().

291  {
292  if (callback) {
294  .WillOnce(testing::Invoke(callback));
295  } else {
296  EXPECT_CALL(*this, onError(testing::_));
297  }
298  }
virtual void onError(const HTTPException &error) noexcept=0
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void proxygen::MockHTTPHandler::expectGoaway ( std::function< void(ErrorCode)>  callback = std::function<void(ErrorCode)>())
inline

Definition at line 300 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::Invoke().

301  {
302  if (callback) {
304  .WillOnce(testing::Invoke(callback));
305  } else {
307  }
308  }
virtual void onGoaway(ErrorCode) noexcept
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void proxygen::MockHTTPHandler::expectHeaders ( std::function< void()>  callback = std::function<void()>())
inline

Definition at line 208 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::InvokeWithoutArgs().

Referenced by TEST_F().

208  {
209  if (callback) {
211  .WillOnce(testing::InvokeWithoutArgs(callback))
212  .RetiresOnSaturation();
213  } else {
215  }
216  }
void onHeadersComplete(std::unique_ptr< HTTPMessage > msg) noexceptoverride
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void proxygen::MockHTTPHandler::expectHeaders ( std::function< void(std::shared_ptr< HTTPMessage >)>  cb)
inline

Definition at line 218 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::Invoke().

218  {
220  .WillOnce(testing::Invoke(cb))
221  .RetiresOnSaturation();
222  }
void onHeadersComplete(std::unique_ptr< HTTPMessage > msg) noexceptoverride
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void proxygen::MockHTTPHandler::expectTrailers ( std::function< void(std::shared_ptr< HTTPHeaders > trailers)>  cb)
inline

Definition at line 224 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::Invoke().

225  {
227  .WillOnce(testing::Invoke(cb))
228  .RetiresOnSaturation();
229  }
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void onTrailers(std::unique_ptr< HTTPHeaders > trailers) noexceptoverride
void proxygen::MockHTTPHandler::expectTransaction ( std::function< void(HTTPTransaction *txn)>  callback)
inline

Definition at line 197 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and testing::Invoke().

Referenced by TEST_F().

197  {
199  .WillOnce(testing::Invoke(callback))
200  .RetiresOnSaturation();
201  }
virtual void setTransaction(HTTPTransaction *txn) noexcept=0
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
void proxygen::MockHTTPHandler::expectTransaction ( HTTPTransaction **  pTxn = nullptr)
inline

Definition at line 203 of file HTTPSessionMocks.h.

References testing::_, EXPECT_CALL, and proxygen::HTTPHandlerBase::txn_.

203  {
205  .WillOnce(testing::SaveArg<0>(pTxn ? pTxn : &txn_));
206  }
virtual void setTransaction(HTTPTransaction *txn) noexcept=0
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
proxygen::MockHTTPHandler::GMOCK_METHOD0_ ( noexcept  ,
detachTransaction  ,
void()   
)
proxygen::MockHTTPHandler::GMOCK_METHOD0_ ( noexcept  ,
onChunkComplete  ,
void()   
)
proxygen::MockHTTPHandler::GMOCK_METHOD0_ ( noexcept  ,
onEOM  ,
void()   
)
proxygen::MockHTTPHandler::GMOCK_METHOD0_ ( noexcept  ,
onEgressPaused  ,
void()   
)
proxygen::MockHTTPHandler::GMOCK_METHOD0_ ( noexcept  ,
onEgressResumed  ,
void()   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
setTransaction  ,
void(HTTPTransaction *txn)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onHeadersComplete  ,
void(std::shared_ptr< HTTPMessage > msg)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onBody  ,
void(std::shared_ptr< folly::IOBuf > chain)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onChunkHeader  ,
void(size_t length)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onTrailers  ,
void(std::shared_ptr< HTTPHeaders > trailers)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onUpgrade  ,
void(UpgradeProtocol protocol)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onError  ,
void(const HTTPException &error)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onGoaway  ,
void(ErrorCode  
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onPushedTransaction  ,
void(HTTPTransaction *)   
)
proxygen::MockHTTPHandler::GMOCK_METHOD1_ ( noexcept  ,
onExTransaction  ,
void(HTTPTransaction *)   
)
void proxygen::MockHTTPHandler::onBody ( std::unique_ptr< folly::IOBuf chain)
inlineoverridevirtualnoexcept

Can be called multiple times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress().

Implements proxygen::HTTPTransactionHandler.

Definition at line 165 of file HTTPSessionMocks.h.

References GMOCK_NOEXCEPT_METHOD0, and GMOCK_NOEXCEPT_METHOD1.

165  {
166  onBody(std::shared_ptr<folly::IOBuf>(chain.release()));
167  }
void onBody(std::unique_ptr< folly::IOBuf > chain) noexceptoverride
void proxygen::MockHTTPHandler::onHeadersComplete ( std::unique_ptr< HTTPMessage msg)
inlineoverridevirtualnoexcept

Called at most once per transaction. This is usually the first ingress callback. It is possible to get a read error before this however. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress().

Implements proxygen::HTTPTransactionHandler.

Definition at line 158 of file HTTPSessionMocks.h.

References GMOCK_NOEXCEPT_METHOD1.

158  {
159  onHeadersComplete(std::shared_ptr<HTTPMessage>(msg.release()));
160  }
void onHeadersComplete(std::unique_ptr< HTTPMessage > msg) noexceptoverride
void proxygen::MockHTTPHandler::onTrailers ( std::unique_ptr< HTTPHeaders trailers)
inlineoverridevirtualnoexcept

Can be called any number of times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). Trailers can be received once right before the EOM of a chunked HTTP/1.1 reponse or multiple times per transaction from SPDY and HTTP/2.0 HEADERS frames.

Implements proxygen::HTTPTransactionHandler.

Definition at line 174 of file HTTPSessionMocks.h.

References folly::pushmi::operators::error(), GMOCK_NOEXCEPT_METHOD0, and GMOCK_NOEXCEPT_METHOD1.

174  {
175  onTrailers(std::shared_ptr<HTTPHeaders>(trailers.release()));
176  }
void onTrailers(std::unique_ptr< HTTPHeaders > trailers) noexceptoverride

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