<commit_before>#include "network-reply.h"
#include <utility>
#include "custom-network-access-manager.h"


NetworkReply::NetworkReply(QNetworkRequest request, CustomNetworkAccessManager *manager, QObject *parent)
	: QObject(parent), m_request(std::move(request)), m_manager(manager)
{
	init();
}

NetworkReply::NetworkReply(QNetworkRequest request, QByteArray data, CustomNetworkAccessManager *manager, QObject *parent)
	: QObject(parent), m_request(std::move(request)), m_data(std::move(data)), m_manager(manager), m_post(true)
{
	init();
}

void NetworkReply::init()
{
	timer.setSingleShot(true);
	connect(&timer, &QTimer::timeout, this, &NetworkReply::startNow);
}


QUrl NetworkReply::url() const
{
	if (m_reply != nullptr) {
		return m_reply->url();
	}
	return m_request.url();
}

QVariant NetworkReply::attribute(QNetworkRequest::Attribute code) const
{
	if (m_reply != nullptr) {
		return m_reply->attribute(code);
	}
	return QVariant();
}

QByteArray NetworkReply::readAll()
{
	return m_reply->readAll();
}

qint64 NetworkReply::bytesAvailable() const
{
	return m_reply->bytesAvailable();
}

QNetworkReply::NetworkError NetworkReply::error() const
{
	if (m_reply != nullptr) {
		return m_reply->error();
	}
	return QNetworkReply::NetworkError::NoError;
}

QString NetworkReply::errorString() const
{
	if (m_reply != nullptr) {
		return m_reply->errorString();
	}
	return QString();
}

QNetworkReply *NetworkReply::networkReply() const
{
	return m_reply;
}

QByteArray NetworkReply::rawHeader(const QByteArray &headerName) const
{
	return m_reply->rawHeader(headerName);
}


bool NetworkReply::isRunning() const
{
	if (!m_started && !m_aborted) {
		return true;
	}
	return m_reply != nullptr && m_reply->isRunning();
}


void NetworkReply::start(int msDelay)
{
	if (m_started) {
		return;
	}
	if (m_aborted) {
		m_aborted = false;
		return;
	}
	m_started = true;

	timer.setInterval(msDelay);
	timer.start();
}<commit_msg>Fix possible crash when getting data from an aborted reply<commit_after>#include "network-reply.h"
#include <utility>
#include "custom-network-access-manager.h"


NetworkReply::NetworkReply(QNetworkRequest request, CustomNetworkAccessManager *manager, QObject *parent)
	: QObject(parent), m_request(std::move(request)), m_manager(manager)
{
	init();
}

NetworkReply::NetworkReply(QNetworkRequest request, QByteArray data, CustomNetworkAccessManager *manager, QObject *parent)
	: QObject(parent), m_request(std::move(request)), m_data(std::move(data)), m_manager(manager), m_post(true)
{
	init();
}

void NetworkReply::init()
{
	timer.setSingleShot(true);
	connect(&timer, &QTimer::timeout, this, &NetworkReply::startNow);
}


QUrl NetworkReply::url() const
{
	if (m_reply != nullptr) {
		return m_reply->url();
	}
	return m_request.url();
}

QVariant NetworkReply::attribute(QNetworkRequest::Attribute code) const
{
	if (m_reply != nullptr) {
		return m_reply->attribute(code);
	}
	return QVariant();
}

QByteArray NetworkReply::readAll()
{
	if (m_reply != nullptr) {
		return m_reply->readAll();
	}
	return {};
}

qint64 NetworkReply::bytesAvailable() const
{
	if (m_reply != nullptr) {
		return m_reply->bytesAvailable();
	}
	return 0;
}

QNetworkReply::NetworkError NetworkReply::error() const
{
	if (m_reply != nullptr) {
		return m_reply->error();
	}
	return QNetworkReply::NetworkError::NoError;
}

QString NetworkReply::errorString() const
{
	if (m_reply != nullptr) {
		return m_reply->errorString();
	}
	return QString();
}

QNetworkReply *NetworkReply::networkReply() const
{
	return m_reply;
}

QByteArray NetworkReply::rawHeader(const QByteArray &headerName) const
{
	if (m_reply != nullptr) {
		return m_reply->rawHeader(headerName);
	}
	return {};
}


bool NetworkReply::isRunning() const
{
	if (!m_started && !m_aborted) {
		return true;
	}
	return m_reply != nullptr && m_reply->isRunning();
}


void NetworkReply::start(int msDelay)
{
	if (m_started) {
		return;
	}
	if (m_aborted) {
		m_aborted = false;
		return;
	}
	m_started = true;

	timer.setInterval(msDelay);
	timer.start();
}
{'fraction_non_alphanumeric': 0.14767932489451477, 'fraction_numerical': 0.0012410027302060065, 'mean_word_length': 6.120141342756184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6255281', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1384, 'n_words': 274}