42 #include "qplatformdefs.h" 47 #include "QtCore/qshareddata.h" 48 #include "QtCore/qlocale.h" 49 #include "QtCore/qdatetime.h" 52 #ifndef QT_NO_DATESTRING 295 #ifndef QT_NO_OPENSSL
298 { qRegisterMetaType<QNetworkRequest>(); }
301 #ifndef QT_NO_OPENSSL 313 #ifndef QT_NO_OPENSSL 322 return url == other.
url &&
331 #ifndef QT_NO_OPENSSL 373 return d == other.
d || *
d == *other.
d;
535 #ifndef QT_NO_OPENSSL 658 return "Content-Type";
661 return "Content-Length";
667 return "Last-Modified";
676 return "Content-Disposition";
694 switch (value.
type()) {
703 switch (value.
type()) {
715 if (cookies.
isEmpty() && value.
userType() == qMetaTypeId<QNetworkCookie>())
716 cookies << qvariant_cast<QNetworkCookie>(value);
731 if (cookies.
isEmpty() && value.
userType() == qMetaTypeId<QNetworkCookie>())
732 cookies << qvariant_cast<QNetworkCookie>(value);
754 switch (tolower(headerName.
at(0))) {
792 foreach (
const QByteArray &cookie, cookieList) {
794 if (parsed.
count() != 1)
846 for ( ; it !=
end; ++
it)
862 end = rawHeaders.constEnd();
863 for ( ; it !=
end; ++
it)
875 setRawHeaderInternal(key, value);
876 parseAndSetHeader(key, value);
892 cookedHeaders.clear();
897 for ( ; it !=
end; ++
it)
898 parseAndSetHeader(it->first, it->second);
907 qWarning(
"QNetworkRequest::setHeader: invalid header value KnownHeader(%d) received", header);
913 cookedHeaders.remove(header);
917 qWarning(
"QNetworkRequest::setHeader: QVariant of type %s cannot be used with header %s",
922 setRawHeaderInternal(name, rawValue);
923 cookedHeaders.insert(header, value);
930 while (it != rawHeaders.end()) {
932 it = rawHeaders.erase(it);
952 cookedHeaders.remove(parsedKey);
969 switch (month_str[0]) {
971 switch (month_str[1]) {
976 switch (month_str[2] ) {
990 switch (month_str[2] ) {
1000 switch (month_str[1]) {
1036 #ifndef QT_NO_DATESTRING 1045 int day, year, hour, minute, second;
1046 if (sscanf(value.
constData(),
"%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, &year, &hour, &minute, &second) == 6)
1056 #endif // QT_NO_DATESTRING The QVariant class acts like a union for the most common Qt data types.
QNetworkRequestPrivate(const QNetworkRequestPrivate &other)
void setUrl(const QUrl &url)
Sets the URL this network request is referring to to be url.
QObject * originatingObject() const
Returns a reference to the object that initiated this network request; returns 0 if not set or the ob...
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
#define QT_END_NAMESPACE
This macro expands to.
bool hasRawHeader(const QByteArray &headerName) const
Returns true if the raw header headerName is present in this network request.
QSslConfiguration sslConfiguration() const
Returns this network request's SSL configuration.
QNetworkRequest(const QUrl &url=QUrl())
Constructs a QNetworkRequest object with url as the URL to be requested.
int remove(const Key &key)
Removes all the items that have the key from the hash.
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
#define it(className, varName)
QByteArray & append(char c)
Appends the character ch to this byte array.
QByteArray rawHeader(const QByteArray &headerName) const
Returns the raw form of header headerName.
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the byte array converted to a {long long} using base base, which is 10 by default and must be...
QDateTime toDateTime(const QString &string, FormatType format=LongFormat) const
Parses the date/time string given in string and returns the time.
The QByteArray class provides an array of bytes.
QVariant attribute(Attribute code, const QVariant &defaultValue=QVariant()) const
Returns the attribute associated with the code code.
QSharedDataPointer< QNetworkRequestPrivate > d
QNetworkRequest & operator=(const QNetworkRequest &other)
Creates a copy of other.
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
bool operator==(const QNetworkRequest &other) const
Returns true if this object is the same as other (i.e., if they have the same URL, same headers and same meta-data settings).
Priority
This enum lists the possible network request priorities.
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
static int name_to_month(const char *month_str)
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
static QVariant parseCookieHeader(const QByteArray &raw)
KnownHeaders
List of known header types that QNetworkRequest parses.
QString toString(qlonglong i) const
Returns a localized string representation of i.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
const T value(const Key &key) const
Returns the value associated with the key.
void setAttribute(Attribute code, const QVariant &value)
Sets the attribute associated with code code to be value value.
iterator Iterator
Qt-style synonym for QList::iterator.
bool operator==(const QNetworkRequestPrivate &other) const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
QUrl url() const
Returns the URL this network request is referring to.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
static QList< QNetworkCookie > parseCookies(const QByteArray &cookieString)
Parses the cookie string cookieString as received from a server response in the "Set-Cookie:" header...
void setPriority(Priority priority)
Set the priority of this request to priority.
QByteArray toRawForm(RawForm form=Full) const
Returns the raw form of this QNetworkCookie.
QNetworkRequest::Priority priority
static QDateTime fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the QDateTime represented by the string, using the format given, or an invalid datetime if th...
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QVariant header(KnownHeaders header) const
Returns the value of the known network header header if it is present in this request.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray trimmed() const
Returns a byte array that has whitespace removed from the start and the end.
QSslConfiguration * sslConfiguration
Q_CORE_EXPORT void qWarning(const char *,...)
void setSslConfiguration(const QSslConfiguration &configuration)
Sets this network request's SSL configuration to be config.
static QSslConfiguration defaultConfiguration()
Returns the default SSL configuration to be used in new SSL connections.
void setTimeSpec(Qt::TimeSpec spec)
Sets the time specification used in this datetime to spec.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
bool isNull() const
Returns true if this byte array is null; otherwise returns false.
void setHeader(KnownHeaders header, const QVariant &value)
Sets the value of the known header header to be value, overriding any previously set headers...
const char * typeName() const
Returns the name of the type stored in the variant.
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
static QVariant parseHttpDate(const QByteArray &raw)
Attribute
Attribute codes for the QNetworkRequest and QNetworkReply.
~QNetworkRequestPrivate()
QByteArray toEncoded(FormattingOptions options=None) const
Returns the encoded representation of the URL if it's valid; otherwise an empty QByteArray is returne...
T & first()
Returns a reference to the first item in the list.
The QNetworkCookie class holds one network cookie.
const char * constData() const
Returns a pointer to the data stored in the byte array.
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
void setRawHeader(const QByteArray &headerName, const QByteArray &value)
Sets the header headerName to be of value headerValue.
QString scheme() const
Returns the scheme of the URL.
int userType() const
Returns the storage type of the value stored in the variant.
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
The QDateTime class provides date and time functions.
Priority priority() const
Return the priority of this request.
The QSharedData class is a base class for shared data objects.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
void setOriginatingObject(QObject *object)
Allows setting a reference to the object initiating the request.
T qvariant_cast(const QVariant &)
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
~QNetworkRequest()
Disposes of the QNetworkRequest object.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
static QNetworkRequest::KnownHeaders parseHeaderName(const QByteArray &headerName)
The QSslConfiguration class holds the configuration and state of an SSL connection.
QList< QByteArray > rawHeaderList() const
Returns a list of all raw headers that are set in this network request.
static QUrl fromEncoded(const QByteArray &url)
Parses input and returns the corresponding QUrl.
Q_CORE_EXPORT int qstricmp(const char *, const char *)
char at(int i) const
Returns the character at index position i in the byte array.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
static const KeyPair *const end
static QByteArray headerValue(QNetworkRequest::KnownHeaders header, const QVariant &value)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QByteArray &value)