You get an interesting situation here in the overridden method QCustomNetworkAccessManager::createRequest() :
- create a
QNetworkRequest request by receiving a QNetworkReply response; - wait until the request is executed and the response is filled with data without leaving the method of creating the request;
- Create a new QCustomNetworkReply custom response
QCustomNetworkReply and copy the headers and received content from the existing response, the latter, in addition to QNetworkReply opening its own QIODevice instance, is transferred to a separate QByteArray ; - return the received "custom response".
Your "custom" answer is not an exact copy of the real answer. You did not redefine all the methods that handle the data, limiting QCustomNetworkReply::readData() only to QCustomNetworkReply::readData() . And there are many, because QNetworkReply inherited from QIODevice . Since your "custom" response contains, albeit an open, but empty QIODevice instance, when you call it, any other undefined method will, as they say, undefined behavior. This is probably the reason for the segfolt, since the web page that you cited as an example performs many downloads of various content. Not surprisingly, on a relatively static page with Yandex from the second example, an error does not occur, whereas in the first case a “crash” occurs.
Also, you missed the moment that the object of the real answer class remains active, you do not delete it after creating the "custom" answer, which means it will live as long as the object of the QCustomNetworkAccessManager class QCustomNetworkAccessManager . Since the latter usually exists throughout the life of the entire program, a bunch of real answers will be accumulated in memory.
The purpose of entering a separate class "custom" answer is unknown to me, but probably you should change the approach.