<commit_before>/*
 * High level "Local HTTP" client.
 *
 * author: <NAME> <<EMAIL>>
 */

#include "lhttp_request.hxx"
#include "lhttp_stock.hxx"
#include "lhttp_address.hxx"
#include "http_response.hxx"
#include "http_client.hxx"
#include "http_headers.hxx"
#include "lease.hxx"
#include "istream/istream.hxx"
#include "header_writer.hxx"
#include "pool.hxx"

struct lhttp_request {
    struct pool *pool;

    LhttpStock *lhttp_stock;
    StockItem *stock_item;
};

/*
 * socket lease
 *
 */

static void
lhttp_socket_release(bool reuse, void *ctx)
{
    struct lhttp_request *request = (struct lhttp_request *)ctx;

    lhttp_stock_put(request->lhttp_stock, *request->stock_item, !reuse);
}

static const struct lease lhttp_socket_lease = {
    .release = lhttp_socket_release,
};

/*
 * constructor
 *
 */

void
lhttp_request(struct pool &pool, LhttpStock &lhttp_stock,
              const LhttpAddress &address,
              http_method_t method, HttpHeaders &&headers,
              struct istream *body,
              const struct http_response_handler &handler, void *handler_ctx,
              struct async_operation_ref &async_ref)
{
    GError *error = nullptr;
    if (!address.options.Check(&error)) {
        if (body != nullptr)
            istream_close(body);

        handler.InvokeAbort(handler_ctx, error);
        return;
    }

    auto request = NewFromPool<struct lhttp_request>(pool);
    request->pool = &pool;
    request->lhttp_stock = &lhttp_stock;<commit_msg>lhttp_request: remove unused attribute "pool"<commit_after>/*
 * High level "Local HTTP" client.
 *
 * author: <NAME> <<EMAIL>>
 */

#include "lhttp_request.hxx"
#include "lhttp_stock.hxx"
#include "lhttp_address.hxx"
#include "http_response.hxx"
#include "http_client.hxx"
#include "http_headers.hxx"
#include "lease.hxx"
#include "istream/istream.hxx"
#include "header_writer.hxx"
#include "pool.hxx"

struct lhttp_request {
    LhttpStock *lhttp_stock;
    StockItem *stock_item;
};

/*
 * socket lease
 *
 */

static void
lhttp_socket_release(bool reuse, void *ctx)
{
    struct lhttp_request *request = (struct lhttp_request *)ctx;

    lhttp_stock_put(request->lhttp_stock, *request->stock_item, !reuse);
}

static const struct lease lhttp_socket_lease = {
    .release = lhttp_socket_release,
};

/*
 * constructor
 *
 */

void
lhttp_request(struct pool &pool, LhttpStock &lhttp_stock,
              const LhttpAddress &address,
              http_method_t method, HttpHeaders &&headers,
              struct istream *body,
              const struct http_response_handler &handler, void *handler_ctx,
              struct async_operation_ref &async_ref)
{
    GError *error = nullptr;
    if (!address.options.Check(&error)) {
        if (body != nullptr)
            istream_close(body);

        handler.InvokeAbort(handler_ctx, error);
        return;
    }

    auto request = NewFromPool<struct lhttp_request>(pool);
    request->lhttp_stock = &lhttp_stock;
{'fraction_non_alphanumeric': 0.11625549172017574, 'fraction_numerical': 0.0, 'mean_word_length': 3.464555052790347, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, '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': '77233', 'n_tokens_mistral': 986, 'n_tokens_neox': 971, 'n_words': 214}