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

Added Expect header

parent bddf6aae
......@@ -454,7 +454,7 @@ Endpoint::serve()
if (!handler_)
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_);
if (listener.bind()) {
......
......@@ -110,6 +110,11 @@ enum class Version {
Http11 // HTTP/1.1
};
enum class Expectation {
Continue,
Ext
};
class CacheDirective {
public:
enum Directive { NoCache, NoStore, MaxAge, MaxStale, MinFresh,
......
......@@ -270,6 +270,22 @@ void
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
Host::parse(const std::string& data) {
auto pos = data.find(':');
......
......@@ -262,6 +262,25 @@ private:
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 {
public:
NAME("Host");
......
......@@ -21,11 +21,13 @@ namespace {
}
RegisterHeader(Accept);
RegisterHeader(Allow);
RegisterHeader(CacheControl);
RegisterHeader(ContentEncoding);
RegisterHeader(ContentLength);
RegisterHeader(ContentType);
RegisterHeader(Date);
RegisterHeader(Expect);
RegisterHeader(Host);
RegisterHeader(Server);
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