kodi
HTTPFileHandler.h
1 /*
2  * Copyright (C) 2015-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "XBDateTime.h"
12 #include "network/httprequesthandler/IHTTPRequestHandler.h"
13 
14 #include <string>
15 
17 {
18 public:
19  ~CHTTPFileHandler() override = default;
20 
21  MHD_RESULT HandleRequest() override;
22 
23  bool CanHandleRanges() const override { return m_canHandleRanges; }
24  bool CanBeCached() const override { return m_canBeCached; }
25  bool GetLastModifiedDate(CDateTime &lastModified) const override;
26 
27  std::string GetRedirectUrl() const override { return m_url; }
28  std::string GetResponseFile() const override { return m_url; }
29 
30 protected:
32  explicit CHTTPFileHandler(const HTTPRequest &request);
33 
34  void SetFile(const std::string& file, int responseStatus);
35 
36  void SetCanHandleRanges(bool canHandleRanges) { m_canHandleRanges = canHandleRanges; }
37  void SetCanBeCached(bool canBeCached) { m_canBeCached = canBeCached; }
38  void SetLastModifiedDate(const struct __stat64 *buffer);
39 
40 private:
41  std::string m_url;
42 
43  bool m_canHandleRanges = true;
44  bool m_canBeCached = true;
45 
46  CDateTime m_lastModified;
47 
48 };
Definition: IHTTPRequestHandler.h:66
bool CanBeCached() const override
Whether the HTTP response can be cached.
Definition: HTTPFileHandler.h:24
MHD_RESULT HandleRequest() override
Handles the HTTP request.
Definition: HTTPFileHandler.cpp:28
Definition: HTTPFileHandler.h:16
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63
bool GetLastModifiedDate(CDateTime &lastModified) const override
Returns the last modification date of the response data.
Definition: HTTPFileHandler.cpp:33
bool CanHandleRanges() const override
Whether the HTTP response could also be provided in ranges.
Definition: HTTPFileHandler.h:23
std::string GetResponseFile() const override
Returns the path to the file that should be returned as the response.
Definition: HTTPFileHandler.h:28
Definition: IHTTPRequestHandler.h:85
std::string GetRedirectUrl() const override
Returns the URL to which the request should be redirected.
Definition: HTTPFileHandler.h:27