s1st
s1st

Reputation: 21

How to delete a header from a QNetworkrequest?

I would like to build a custom SOAP-Request with Qt. For my specific SOAP-action packet I need to remove the Accept-Language header which is automatically present in the QNetworkrequest.

It would be really handy to have the opposite of:

QNetworkRequest browseRequest;
browseRequest.setRawHeader(QByteArray("Accept-Language"), QByteArray("english"));

For example:

browseRequest.deletePartOfHeader(QByteArray("Accept-Language"));

Edit: Went with a QTcpSocket and sent the needed String. Found no other solution.

Upvotes: 1

Views: 922

Answers (1)

MrEricSir
MrEricSir

Reputation: 8242

Unfortunately I don't believe this is possible (yet) with QNetworkRequest. See bug QTBUG-9463, "QNetworkRequest: Be able to unset some of the optional header entries".

The bug report's description mentions your case specifically:

QNetworkRequest: Be able to unset some of the optional header entries such as Accept-Encoding and Accept-Language as they do not have to be in the header, but currently there is no way to unset them.

(Emphasis mine.)

Upvotes: 1

Related Questions