API CHANGE: response status is now set on processResponseHeaders

That change was needed to move the variable attribution to earliest
as possible. We also have a new field for HTTP_PROTOCOL version used
on the response.
This commit is contained in:
Felipe Zimmerle
2016-06-20 23:57:02 -03:00
parent a36b2da86a
commit b8bd0c5960
6 changed files with 37 additions and 23 deletions

View File

@@ -823,16 +823,22 @@ int Transaction::appendRequestBody(const unsigned char *buf, size_t len) {
*
* @note Remember to check for a possible intervention.
*
* @param code The returned http code.
* @param proto Protocol used on the response.
*
* @returns If the operation was successful or not.
* @retval true Operation was successful.
* @retval false Operation failed.
*
*/
int Transaction::processResponseHeaders() {
int Transaction::processResponseHeaders(int code, const std::string& proto) {
#ifndef NO_LOGS
debug(4, "Starting phase RESPONSE_HEADERS. (SecRules 3)");
#endif
this->m_httpCodeReturned = code;
this->m_collections.store("STATUS", std::to_string(code));
if (m_rules->secRuleEngine == Rules::DisabledRuleEngine) {
#ifndef NO_LOGS
debug(4, "Rule engine disabled, returning...");
@@ -1123,7 +1129,7 @@ int Transaction::getResponseBodyLenth() {
* @retval false Operation failed.
*
*/
int Transaction::processLogging(int returned_code) {
int Transaction::processLogging() {
#ifndef NO_LOGS
debug(4, "Starting phase LOGGING. (SecRules 5)");
#endif
@@ -1135,9 +1141,6 @@ int Transaction::processLogging(int returned_code) {
return true;
}
this->m_httpCodeReturned = returned_code;
this->m_collections.store("STATUS", std::to_string(returned_code));
this->m_rules->evaluate(ModSecurity::LoggingPhase, this);
/* If relevant, save this transaction information at the audit_logs */
@@ -1720,8 +1723,9 @@ extern "C" int msc_request_body_from_file(Transaction *transaction,
* @retval 0 Operation failed.
*
*/
extern "C" int msc_process_response_headers(Transaction *transaction) {
return transaction->processResponseHeaders();
extern "C" int msc_process_response_headers(Transaction *transaction,
int code, const char* protocol) {
return transaction->processResponseHeaders(code, protocol);
}
@@ -1961,15 +1965,14 @@ extern "C" int msc_get_response_body_length(Transaction *transaction) {
* delivered prior to the execution of this function.
*
* @param transaction ModSecurity transaction.
* @param code HTTP code returned to the user.
*
* @returns If the operation was successful or not.
* @retval 1 Operation was successful.
* @retval 0 Operation failed.
*
*/
extern "C" int msc_process_logging(Transaction *transaction, int code) {
return transaction->processLogging(code);
extern "C" int msc_process_logging(Transaction *transaction) {
return transaction->processLogging();
}
} // namespace modsecurity