#ifndef PQNETWORKREQUEST_H
#define PQNETWORKREQUEST_H

#include <QNetworkRequest>
#include <pqobject.h>

class PQNetworkRequest : public PQObject, public QNetworkRequest
{
    Q_OBJECT
    PQ_OBJECT_EX(QNetworkRequest)

    Q_PROPERTY(QString url READ url WRITE setUrl)
    Q_PROPERTY(int maximumRedirectsAllowed READ maximumRedirectsAllowed WRITE setMaximumRedirectsAllowed)

public:
    Q_INVOKABLE explicit PQNetworkRequest(const QString &url = QString());
    explicit PQNetworkRequest(const QNetworkRequest &other);
    ~PQNetworkRequest();

    Q_INVOKABLE QString url() const;
    Q_INVOKABLE void setUrl(const QString &url);

    Q_INVOKABLE QVariant header(int header) const;
    Q_INVOKABLE void setHeader(int header, const QVariant &value);

    Q_INVOKABLE bool hasRawHeader(const QByteArray &headerName) const;
    Q_INVOKABLE QList<QByteArray> rawHeaderList() const;
    Q_INVOKABLE QByteArray rawHeader(const QByteArray &headerName) const;
    Q_INVOKABLE void setRawHeader(const QByteArray &headerName, const QByteArray &value);

    Q_INVOKABLE QVariant attribute(int code, const QVariant &defaultValue = QVariant()) const;
    Q_INVOKABLE void setAttribute(int code, const QVariant &value);

    Q_INVOKABLE int maximumRedirectsAllowed() const;
    Q_INVOKABLE void setMaximumRedirectsAllowed(int maximumRedirectsAllowed);

public slots:
    PQ_ON_SIGNAL_DECL_START {
        PQOBJECT_ON_SIGNALS();
    } PQ_ON_SIGNAL_DECL_END
};

Q_DECLARE_METATYPE(QNetworkRequest*)
Q_DECLARE_METATYPE(PQNetworkRequest*)

#endif // PQNETWORKREQUEST_H
