Shaka Packager SDK
Loading...
Searching...
No Matches
http_key_fetcher.h
1// Copyright 2014 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_MEDIA_BASE_HTTP_KEY_FETCHER_H_
8#define PACKAGER_MEDIA_BASE_HTTP_KEY_FETCHER_H_
9
10#include <cstdint>
11#include <string>
12#include <vector>
13
14#include <packager/file/http_file.h>
15#include <packager/macros/classes.h>
16#include <packager/media/base/key_fetcher.h>
17#include <packager/status.h>
18
19namespace shaka {
20namespace media {
21
27class HttpKeyFetcher : public KeyFetcher {
28 public:
33 HttpKeyFetcher(int32_t timeout_in_seconds);
34 ~HttpKeyFetcher() override;
35
37 Status FetchKeys(const std::string& url,
38 const std::string& request,
39 std::string* response) override;
40
46 virtual Status Get(const std::string& url, std::string* response);
47
53 virtual Status Post(const std::string& url,
54 const std::string& data,
55 std::string* response);
56
59 void set_content_type(const std::string& content_type) {
60 content_type_ = content_type;
61 }
62
64 void set_extra_headers(const std::vector<std::string>& extra_headers) {
65 extra_headers_ = extra_headers;
66 }
67
68 private:
69 Status FetchInternal(HttpMethod method,
70 const std::string& url,
71 const std::string& data,
72 std::string* response);
73
74 const int32_t timeout_in_seconds_;
75 std::string content_type_;
76 std::vector<std::string> extra_headers_;
77
78 DISALLOW_COPY_AND_ASSIGN(HttpKeyFetcher);
79};
80
81} // namespace media
82} // namespace shaka
83
84#endif // PACKAGER_MEDIA_BASE_HTTP_KEY_FETCHER_H_
HttpKeyFetcher()
Creates a fetcher with no timeout.
void set_extra_headers(const std::vector< std::string > &extra_headers)
Sets extra HTTP headers, in "Name: value" form, to send with requests.
void set_content_type(const std::string &content_type)
virtual Status Post(const std::string &url, const std::string &data, std::string *response)
virtual Status Get(const std::string &url, std::string *response)
Status FetchKeys(const std::string &url, const std::string &request, std::string *response) override
Base class for fetching keys from the license service.
Definition key_fetcher.h:19
All the methods that are virtual are virtual for mocking.