Update connection to negotiate extensions for clients

This commit is contained in:
Peter Thorson committed 2015-02-27 07:47:31 -05:00
1 parent 643e7a0ce1
commit c39412ee38
2 files changed
+25 -1

No files matched your search

+6 -1
View File
@@ -140,7 +140,10 @@ enum value {
unsupported_version,
/// HTTP parse error
http_parse_error
http_parse_error,
/// Extension negotiation failed
extension_neg_failed
}; // enum value
@@ -216,6 +219,8 @@ public:
return "Unsupported version";
case error::http_parse_error:
return "HTTP parse error";
case error::extension_neg_failed:
return "Extension negotiation failed";
default:
return "Unknown";
}
+19
View File
@@ -1532,6 +1532,25 @@ void connection<config>::handle_read_http_response(lib::error_code const & ec,
return;
}
// Read extension parameters and set up values necessary for the end
// user to complete extension negotiation.
std::pair<lib::error_code,std::string> neg_results;
neg_results = m_processor->negotiate_extensions(m_response);
if (neg_results.first) {
// There was a fatal error in extension negotiation. For the moment
// kill all connections that fail extension negotiation.
// TODO: deal with cases where the response is well formed but
// doesn't match the options requested by the client. Its possible
// that the best behavior in this cases is to log and continue with
// an unextended connection.
m_alog.write(log::alevel::devel, "Extension negotiation failed: "
+ neg_results.first.message());
this->terminate(make_error_code(error::extension_neg_failed));
// TODO: close connection with reason 1010 (and list extensions)
}
// response is valid, connection can now be assumed to be open
m_internal_state = istate::PROCESS_CONNECTION;
m_state = session::state::open;