Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Fix compilation with MSVC 2010
Browse files Browse the repository at this point in the history
Issue #10158: #10158
This bug introduced by the marco max( ) defined in <windef.h>.
It replaces max( ) with another statement but still preceeded by numberic_limits<Type>::
The workaround is to use the parenthesis
  • Loading branch information
vitallium authored and ariya committed Apr 14, 2013
1 parent 78242e5 commit 3edcabe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/networkaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR

// http://code.google.com/p/phantomjs/issues/detail?id=337
if (op == QNetworkAccessManager::PostOperation) {
if (outgoingData) postData = outgoingData->peek(std::numeric_limits < qint64 >::max());
if (outgoingData) postData = outgoingData->peek((std::numeric_limits<qint64>::max)());
QString contentType = req.header(QNetworkRequest::ContentTypeHeader).toString();
if (contentType.isEmpty()) {
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
Expand Down

6 comments on commit 3edcabe

@zhaolong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried MSVC2008?
When run the test.I always got a error: [FATAL] In file tools\qbytearray.cpp, line 1416: Out of memory
1

@zhaolong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a test:

    QFile file("in.txt");
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        ;

    QByteArray postData;
    postData = file.peek(std::numeric_limits<qint16>::max()); // OK
    postData = file.peek(std::numeric_limits<qint32>::max()); // CRASH
    postData = file.peek(std::numeric_limits<qint64>::max()); // CRASH

It seems like 'std::numeric_limits::max()' is too big!

@vitallium
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, got it too. I think we should limit postData size to 10 Mb(?)

@JamesMGreene
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there isn't any HTTP limitation on the size of a POST request, so these limitations are all configured at the web server level. Theoretically, you could accept a file as large as the server's available (free) memory (minus the memory needed for processing the request afterward, etc.).

Some defaults:

  • IIS 7.x: ~30MB [ref]
  • Apache 2.0: 0 (unlimited), or max size of 2GB if not unlimited [ref]
  • Tomcat 7.0: 2MB [ref]
  • Nginx 1.2.0: 1MB [ref]

@vitallium
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I meant to limit the size of the data which will be passed in the requestData

UPDATE
Like it was done in Webkit Developer Tools. There is a limit in 10 Mb for a request's data size. [ref]

@JamesMGreene
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, I was just trying to add background info and some common defaults to consider for our users' best interests. I think 10MB sounds good. I also think that this is something we should try to control at the build script/config level so it's easy to update for custom builds if anyone needs a higher limit.

Please sign in to comment.