-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added default user-agent to get requests (#438)
- Loading branch information
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2017-present, Status Research and Development GmbH. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
|
||
#include "reactnetworkaccessmanager.h" | ||
|
||
ReactNetworkAccessManager::ReactNetworkAccessManager(QObject* parent) : QNetworkAccessManager(parent) {} | ||
|
||
QNetworkReply* ReactNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op, | ||
const QNetworkRequest& originalReq, | ||
QIODevice* outgoingData) { | ||
QNetworkRequest requestWithHeader = originalReq; | ||
requestWithHeader.setRawHeader("User-Agent", "react-native-desktop"); | ||
return QNetworkAccessManager::createRequest(op, requestWithHeader, outgoingData); | ||
} | ||
|
||
QNetworkAccessManager* ReactNetworkAccessManagerFactory::create(QObject* parent) { | ||
return new ReactNetworkAccessManager(parent); | ||
} | ||
|
||
#include "reactnetworkaccessmanager.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2017-present, Status Research and Development GmbH. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
|
||
#ifndef REACTNETWORKACCESSMANAGER_H | ||
#define REACTNETWORKACCESSMANAGER_H | ||
|
||
#include <QNetworkAccessManager> | ||
#include <QQmlNetworkAccessManagerFactory> | ||
|
||
class ReactNetworkAccessManager : public QNetworkAccessManager { | ||
Q_OBJECT | ||
|
||
public: | ||
ReactNetworkAccessManager(QObject* parent = nullptr); | ||
|
||
protected: | ||
virtual QNetworkReply* createRequest(QNetworkAccessManager::Operation op, | ||
const QNetworkRequest& originalReq, | ||
QIODevice* outgoingData = nullptr); | ||
}; | ||
|
||
class ReactNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory { | ||
public: | ||
QNetworkAccessManager* create(QObject* parent) override; | ||
}; | ||
|
||
#endif // REACTNETWORKACCESSMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters