Hello guys,
I'll get straight to the point:
In my code (PyQt), I'm Trying to subclass QNetworkAccessManager so that I could get the data in QNetworkReply, without affecting the contents of the reply.
I do this by connecting myself to readyRead, once readyRead is called I peek the size of bytesAvailable and append that to my own attribute containing the data.
When data is unsupported, it is not read and so the buffer is not cleared, I notice that and change the append to an add.

Qt Code:
  1. if reply.isReadable() and reply.isOpen() and reply.bytesAvailable():
  2. reply_data = b''
  3.  
  4. bytes_available = reply.bytesAvailable()
  5. while len(reply_data) < bytes_available:
  6. bytes_to_read = bytes_available - len(reply_data)
  7. reply_data += bytes(reply.peek(bytes_to_read))
  8.  
  9. if hasattr(reply, 'is_unsupported') and reply.is_unsupported:
  10. reply.data = reply_data
  11. else:
  12. reply.data += reply_data
To copy to clipboard, switch view to plain text mode 

However, this still doesn't cover all of the times where the buffer is not cleared, and so at certain times reply.data will appear to hold duplicated data, since it is appended instead of instantiated.

Any helpful insights?