MCPcopy Create free account
hub / github.com/apache/trafficserver / AnotherClass

Class AnotherClass

plugins/experimental/inliner/cache-handler.h:75–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73namespace inliner
74{
75 struct AnotherClass {
76 util::Buffer content_;
77 std::string contentType_;
78 const std::string url_;
79
80 AnotherClass(const std::string &u) : url_(u) {}
81 int64_t
82 data(const TSIOBufferReader r, int64_t l)
83 {
84 assert(r != nullptr);
85 TSIOBufferBlock block = TSIOBufferReaderStart(r);
86
87 assert(l >= 0);
88 if (l == 0) {
89 l = TSIOBufferReaderAvail(r);
90 assert(l >= 0);
91 }
92
93 int64_t length = 0;
94
95 for (; block && l > 0; block = TSIOBufferBlockNext(block)) {
96 int64_t size = 0;
97 const char *const pointer = TSIOBufferBlockReadStart(block, r, &size);
98 if (pointer != nullptr && size > 0) {
99 size = std::min(size, l);
100 std::copy(pointer, pointer + size, std::back_inserter(content_));
101 length += size;
102 l -= size;
103 }
104 }
105
106 return length;
107 }
108
109 void
110 done()
111 {
112 if (GIF::verifySignature(content_)) {
113 contentType_ = "image/gif";
114 } else if (JPEG::verifySignature(content_)) {
115 contentType_ = "image/jpeg";
116 } else if (PNG::verifySignature(content_)) {
117 contentType_ = "image/png";
118 } else {
119 // TODO(dmorilha): check png signature code.
120 Dbg(dbg_ctl, "Invalid signature for: %s", url_.c_str());
121 }
122
123 if (contentType_ != "image/gif" && contentType_ != "image/jpeg" && contentType_ != "image/jpg" &&
124 contentType_ != "image/png") {
125 return;
126 }
127
128 if (!contentType_.empty() && !content_.empty()) {
129 std::string output;
130 output.reserve(content_.size() * 5);
131 output += "data:";
132 output += contentType_;

Callers 1

missMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected