Repository navigation
Expand file tree
/
Copy pathResponseHandler.h
More file actions
84 lines (66 loc) · 2.38 KB
/
Copy pathResponseHandler.h
File metadata and controls
84 lines (66 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include "proxygen/lib/http/session/HTTPTransaction.h"
namespace proxygen {
class RequestHandler;
/**
* Interface that acts as client for RequestHandler. It also has a hook
* for the RequestHandler so that it is easy to chain these Request/Response
* handlers and be able to modify these chains.
*
* The names are pretty much self explanatory. You only need
* to get into details about this interface if you are implementing filters.
*
* NOTE: All the writes are done at the end of the event loop. So this is safe
* to do in your RequestHandler.
*
* {
* ...
* downstream_->sendHeader(...);
* downstream_->sendEOM();
* }
*
* You dont need to worry about any callbacks being invoked after
* sendHeader.
*
* Consider using proxygen/httpserver/ResponseBuilder to send back the
* response. It will take care of chunking response if required and
* everything.
*/
class ResponseHandler {
public:
explicit ResponseHandler(RequestHandler* upstream)
: upstream_(CHECK_NOTNULL(upstream)) {
}
virtual ~ResponseHandler() {}
/**
* NOTE: We take response message as non-const reference, to allow filters
* between your handler and client to be able to modify response
* if they want to.
*
* eg. a compression filter might want to change the content-encoding
*/
virtual void sendHeaders(HTTPMessage& msg) noexcept = 0;
virtual void sendChunkHeader(size_t len) noexcept = 0;
virtual void sendBody(std::unique_ptr<folly::IOBuf> body) noexcept = 0;
virtual void sendChunkTerminator() noexcept = 0;
virtual void sendEOM() noexcept = 0;
virtual void sendAbort() noexcept = 0;
virtual void refreshTimeout() noexcept = 0;
virtual void pauseIngress() noexcept = 0;
virtual void resumeIngress() noexcept = 0;
// Accessors for Transport/Connection information
virtual const TransportInfo& getSetupTransportInfo() const noexcept = 0;
virtual void getCurrentTransportInfo(TransportInfo* tinfo) const = 0;
protected:
RequestHandler* upstream_{nullptr};
};
}