<commit_before>/*
 * Convert a stream into a stream of FCGI_STDIN packets.
 *
 * author: <NAME> <<EMAIL>>
 */

#include "istream_fcgi.hxx"
#include "FacadeIstream.hxx"
#include "fcgi_protocol.h"
#include "util/Cast.hxx"
#include "util/ByteOrder.hxx"

#include <assert.h>
#include <string.h>

class FcgiIstream : public FacadeIstream {
    size_t missing_from_current_record = 0;

    struct fcgi_record_header header;
    size_t header_sent = sizeof(header);

public:
    FcgiIstream(struct pool &pool, struct istream &_input,
                uint16_t request_id)
        :FacadeIstream(pool, _input,
                       MakeIstreamHandler<FcgiIstream>::handler, this) {
        header = (struct fcgi_record_header){
            .version = FCGI_VERSION_1,
            .type = FCGI_STDIN,
            .request_id = request_id,
            .padding_length = 0,
            .reserved = 0,
        };
    }

    bool WriteHeader();
    void StartRecord(size_t length);
    size_t Feed(const char *data, size_t length);

    /* virtual methods from class Istream */<commit_msg>istream_fcgi: make the class "final"<commit_after>/*
 * Convert a stream into a stream of FCGI_STDIN packets.
 *
 * author: <NAME> <<EMAIL>>
 */

#include "istream_fcgi.hxx"
#include "FacadeIstream.hxx"
#include "fcgi_protocol.h"
#include "util/Cast.hxx"
#include "util/ByteOrder.hxx"

#include <assert.h>
#include <string.h>

class FcgiIstream final : public FacadeIstream {
    size_t missing_from_current_record = 0;

    struct fcgi_record_header header;
    size_t header_sent = sizeof(header);

public:
    FcgiIstream(struct pool &pool, struct istream &_input,
                uint16_t request_id)
        :FacadeIstream(pool, _input,
                       MakeIstreamHandler<FcgiIstream>::handler, this) {
        header = (struct fcgi_record_header){
            .version = FCGI_VERSION_1,
            .type = FCGI_STDIN,
            .request_id = request_id,
            .padding_length = 0,
            .reserved = 0,
        };
    }

    bool WriteHeader();
    void StartRecord(size_t length);
    size_t Feed(const char *data, size_t length);

    /* virtual methods from class Istream */
{'fraction_non_alphanumeric': 0.104176227627352, 'fraction_numerical': 0.005507113354749885, 'mean_word_length': 2.732876712328767, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1847518', 'n_tokens_mistral': 741, 'n_tokens_neox': 710, 'n_words': 169}