Commit 07a0a345 authored by Mathieu Stefani's avatar Mathieu Stefani

Added Expect header

parent bddf6aae
...@@ -454,7 +454,7 @@ Endpoint::serve() ...@@ -454,7 +454,7 @@ Endpoint::serve()
if (!handler_) if (!handler_)
throw std::runtime_error("Must call setHandler() prior to serve()"); throw std::runtime_error("Must call setHandler() prior to serve()");
listener.init(24, Tcp::Options::InstallSignalHandler); listener.init(1, Tcp::Options::InstallSignalHandler);
listener.setHandler(handler_); listener.setHandler(handler_);
if (listener.bind()) { if (listener.bind()) {
......
...@@ -110,6 +110,11 @@ enum class Version { ...@@ -110,6 +110,11 @@ enum class Version {
Http11 // HTTP/1.1 Http11 // HTTP/1.1
}; };
enum class Expectation {
Continue,
Ext
};
class CacheDirective { class CacheDirective {
public: public:
enum Directive { NoCache, NoStore, MaxAge, MaxStale, MinFresh, enum Directive { NoCache, NoStore, MaxAge, MaxStale, MinFresh,
......
...@@ -270,6 +270,22 @@ void ...@@ -270,6 +270,22 @@ void
Date::write(std::ostream& os) const { Date::write(std::ostream& os) const {
} }
void
Expect::parseRaw(const char* str, size_t len) {
if (memcmp(str, "100-continue", len)) {
expectation_ = Expectation::Continue;
} else {
expectation_ = Expectation::Ext;
}
}
void
Expect::write(std::ostream& os) const {
if (expectation_ == Expectation::Continue) {
os << "100-continue";
}
}
void void
Host::parse(const std::string& data) { Host::parse(const std::string& data) {
auto pos = data.find(':'); auto pos = data.find(':');
......
...@@ -262,6 +262,25 @@ private: ...@@ -262,6 +262,25 @@ private:
FullDate fullDate_; FullDate fullDate_;
}; };
class Expect : public Header {
public:
NAME("Expect")
Expect() { }
explicit Expect(Http::Expectation expectation) :
expectation_(expectation)
{ }
void parseRaw(const char* str, size_t len);
void write(std::ostream& os) const;
Http::Expectation expectation() const { return expectation_; }
private:
Expectation expectation_;
};
class Host : public Header { class Host : public Header {
public: public:
NAME("Host"); NAME("Host");
......
...@@ -21,11 +21,13 @@ namespace { ...@@ -21,11 +21,13 @@ namespace {
} }
RegisterHeader(Accept); RegisterHeader(Accept);
RegisterHeader(Allow);
RegisterHeader(CacheControl); RegisterHeader(CacheControl);
RegisterHeader(ContentEncoding); RegisterHeader(ContentEncoding);
RegisterHeader(ContentLength); RegisterHeader(ContentLength);
RegisterHeader(ContentType); RegisterHeader(ContentType);
RegisterHeader(Date); RegisterHeader(Date);
RegisterHeader(Expect);
RegisterHeader(Host); RegisterHeader(Host);
RegisterHeader(Server); RegisterHeader(Server);
RegisterHeader(UserAgent); RegisterHeader(UserAgent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment