<commit_before>// Copyright(c) <NAME> <<EMAIL>>, 2011
//
// This document is covered by the an Open Source Initiative approved license. A
// copy of the license should have been provided alongside this software package
// (see "LICENSE.txt"). If not, terms of the license are available online at
// "http://www.opensource.org/licenses/mit".

#include "Message.hpp"
#include "Error.hpp"
#include "Flags.hpp"
#include "icompare.hpp"

#include <algorithm>
#include <cstring>
#include <utility>

namespace {

    struct Clear {
        typedef std::pair<const std::string, std::string> Header;
        void operator() ( Header& header ) const { header.second.clear(); }
    };

    class Matches
    {
        const std::string& myField;
    public:
        Matches ( const std::string& field )
            : myField(field)
        {}
        bool operator() ( const std::pair<std::string,std::string>& field )
        {
            return (http::ieq(field.first, myField));
        }
    };

}

namespace http {

    int Message::on_message_begin ( ::http_parser * parser )
    {
        Message& message = *static_cast<Message*>(parser->data);
        message.myComplete = false;
        message.myHeadersComplete = false;
        return (0);
    }

    int Message::on_message_complete ( ::http_parser * parser )
    {
        Message& message = *static_cast<Message*>(parser->data);
        message.myComplete = true;
        return (0);
    }<commit_msg>Stop parsing and return after a complete message<commit_after>// Copyright(c) <NAME> <<EMAIL>>, 2011
//
// This document is covered by the an Open Source Initiative approved license. A
// copy of the license should have been provided alongside this software package
// (see "LICENSE.txt"). If not, terms of the license are available online at
// "http://www.opensource.org/licenses/mit".

#include "Message.hpp"
#include "Error.hpp"
#include "Flags.hpp"
#include "icompare.hpp"

#include <algorithm>
#include <cstring>
#include <utility>

namespace {

    struct Clear {
        typedef std::pair<const std::string, std::string> Header;
        void operator() ( Header& header ) const { header.second.clear(); }
    };

    class Matches
    {
        const std::string& myField;
    public:
        Matches ( const std::string& field )
            : myField(field)
        {}
        bool operator() ( const std::pair<std::string,std::string>& field )
        {
            return (http::ieq(field.first, myField));
        }
    };

}

namespace http {

    int Message::on_message_begin ( ::http_parser * parser )
    {
        Message& message = *static_cast<Message*>(parser->data);
        message.myComplete = false;
        message.myHeadersComplete = false;
        return (0);
    }

    int Message::on_message_complete ( ::http_parser * parser )
    {
        Message& message = *static_cast<Message*>(parser->data);
        message.myComplete = true;
        return (1); //return (0);
    }
{'fraction_non_alphanumeric': 0.13213923622845555, 'fraction_numerical': 0.004393376140588037, 'mean_word_length': 2.7468354430379747, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2096131', 'n_tokens_mistral': 864, 'n_tokens_neox': 843, 'n_words': 241}