proxygen
StaticHandler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <folly/Memory.h>
13 #include <folly/File.h>
15 
16 namespace proxygen {
17 class ResponseHandler;
18 }
19 
20 namespace StaticService {
21 
23  public:
24  void onRequest(std::unique_ptr<proxygen::HTTPMessage> headers)
25  noexcept override;
26 
27  void onBody(std::unique_ptr<folly::IOBuf> body) noexcept override;
28 
29  void onEOM() noexcept override;
30 
31  void onUpgrade(proxygen::UpgradeProtocol proto) noexcept override;
32 
33  void requestComplete() noexcept override;
34 
35  void onError(proxygen::ProxygenError err) noexcept override;
36 
37  void onEgressPaused() noexcept override;
38 
39  void onEgressResumed() noexcept override;
40 
41  private:
42  void readFile(folly::EventBase* evb);
43  bool checkForCompletion();
44 
45  std::unique_ptr<folly::File> file_;
46  bool readFileScheduled_{false};
47  std::atomic<bool> paused_{false};
48  bool finished_{false};
49 };
50 
51 }
bool readFile(int fd, Container &out, size_t num_bytes=std::numeric_limits< size_t >::max())
Definition: FileUtil.h:125
requires E e noexcept(noexcept(s.error(std::move(e))))
std::unique_ptr< folly::File > file_
Definition: StaticHandler.h:45