19 #ifndef NET_INSTAWEB_HTTP_PUBLIC_HTTP_VALUE_H_
20 #define NET_INSTAWEB_HTTP_PUBLIC_HTTP_VALUE_H_
24 #include "pagespeed/kernel/base/basictypes.h"
25 #include "pagespeed/kernel/base/shared_string.h"
26 #include "pagespeed/kernel/base/string.h"
27 #include "pagespeed/kernel/base/string_util.h"
28 #include "pagespeed/kernel/base/writer.h"
30 namespace net_instaweb {
32 class ResponseHeaders;
46 bool Empty()
const {
return storage_.empty(); }
63 virtual bool Write(
const StringPiece& str, MessageHandler* handler);
64 virtual bool Flush(MessageHandler* handler);
67 bool ExtractHeaders(ResponseHeaders* headers, MessageHandler* handler)
const;
75 bool unique()
const {
return storage_.unique(); }
82 bool Link(SharedString* src, ResponseHeaders* headers,
83 MessageHandler* handler);
89 storage_ = src->storage_;
90 contents_size_ = src->contents_size();
95 SharedString*
share() {
return &storage_; }
97 size_t size()
const {
return storage_.size(); }
98 int64 contents_size() {
return contents_size_; }
102 static bool Decode(StringPiece encoded_value, GoogleString* http_string,
103 MessageHandler* handler);
105 static bool Encode(StringPiece http_string, GoogleString* encoded_value,
106 MessageHandler* handler);
109 friend class HTTPValueTest;
112 char type_identifier()
const {
return *storage_.data(); }
114 unsigned int SizeOfFirstChunk()
const;
115 void SetSizeOfFirstChunk(
unsigned int size);
116 int64 ComputeContentsSize()
const;
122 SharedString storage_;
124 int64 contents_size_;
static bool Decode(StringPiece encoded_value, GoogleString *http_string, MessageHandler *handler)
Definition: http_value.h:38
bool Link(SharedString *src, ResponseHeaders *headers, MessageHandler *handler)
static bool Encode(StringPiece http_string, GoogleString *encoded_value, MessageHandler *handler)
Convert from raw HTTP stream to HTTPValue format.
bool Empty() const
Is this HTTPValue empty.
Definition: http_value.h:46
SharedString * share()
Access the shared string, for insertion into a cache via Put.
Definition: http_value.h:95
bool ExtractContents(StringPiece *str) const
void Clear()
Clears the value (both headers and content)
bool unique() const
Tests whether this reference is the only active one to the string object.
Definition: http_value.h:75
void SetHeaders(ResponseHeaders *headers)
void Link(HTTPValue *src)
Definition: http_value.h:87
bool ExtractHeaders(ResponseHeaders *headers, MessageHandler *handler) const
Retrieves the headers, returning false if empty.
virtual bool Write(const StringPiece &str, MessageHandler *handler)