{"action":"created","comment":{"url":"https://api.github.com/repos/xtuple/qt-client/pulls/comments/40856547","id":40856547,"diff_hunk":"@@ -0,0 +1,76 @@\n+/*\n+ * This file is part of the xTuple ERP: PostBooks Edition, a free and\n+ * open source Enterprise Resource Planning software suite,\n+ * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n+ * It is licensed to you under the Common Public Attribution License\n+ * version 1.0, the full text of which (including xTuple-specific Exhibits)\n+ * is available at www.xtuple.com/CPAL.  By using this software, you agree\n+ * to be bound by its terms.\n+ */\n+\n+#include \"xtNetworkRequestManager.h\"\n+#include <QNetworkAccessManager>\n+#include <QNetworkRequest>\n+#include <QNetworkReply>\n+#include <QMutex>\n+#include <QMutexLocker>\n+#include <QObject>\n+#include <QDebug>\n+\n+#define DEBUG false\n+\n+xtNetworkRequestManager::xtNetworkRequestManager(const QUrl & url, QMutex &mutex) {\n+  nwam = new QNetworkAccessManager;\n+  _nwrep = 0;\n+  _response = 0;\n+  _mutex = &mutex;\n+  _mutex->lock();\n+  _loop = new QEventLoop;\n+  startRequest(url);\n+}\n+void xtNetworkRequestManager::startRequest(const QUrl & url) {\n+    _nwrep = nwam->get(QNetworkRequest(url));\n+    connect(_nwrep, SIGNAL(finished()), SLOT(requestCompleted()));\n+    connect(nwam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));\n+#if QT_VERSION < 0x050000 //this feels hackish, ignore error or provide root cert, we'll ignore for now\n+    connect(nwam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), _nwrep, SLOT(ignoreSslErrors()));\n+#endif\n+    connect(nwam, SIGNAL(finished(QNetworkReply*)), _loop, SLOT(quit()));\n+    _loop->exec();\n+}\n+void xtNetworkRequestManager::requestCompleted() {\n+  _response = _nwrep->readAll(); //we don't really care here but store it anyways\n+  _nwrep->close();\n+  QVariant possibleRedirect = _nwrep->attribute(QNetworkRequest::RedirectionTargetAttribute);\n+  if(DEBUG){\n+      qDebug() << \"redirect=\" << possibleRedirect;\n+      qDebug() << \"replyError=\" << _nwrep->errorString();\n+      qDebug() << \"replyErrorCode=\" << _nwrep->error();\n+  }\n+  if(_nwrep->error() == QNetworkReply::NoError){\n+      _nwrep->deleteLater();\n+      _mutex->unlock();\n+  }\n+  else if(!possibleRedirect.isNull()){","path":"common/xtNetworkRequestManager.cpp","position":55,"original_position":54,"commit_id":"6d2938bdd00bb57e5f09ba682b58267b5601bb4b","original_commit_id":"3c57f4af4aca58f548290ee1d33fa24049b66c6e","user":{"login":"gilmoskowitz","id":704111,"avatar_url":"https://avatars.githubusercontent.com/u/704111?v=3","gravatar_id":"","url":"https://api.github.com/users/gilmoskowitz","html_url":"https://github.com/gilmoskowitz","followers_url":"https://api.github.com/users/gilmoskowitz/followers","following_url":"https://api.github.com/users/gilmoskowitz/following{/other_user}","gists_url":"https://api.github.com/users/gilmoskowitz/gists{/gist_id}","starred_url":"https://api.github.com/users/gilmoskowitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilmoskowitz/subscriptions","organizations_url":"https://api.github.com/users/gilmoskowitz/orgs","repos_url":"https://api.github.com/users/gilmoskowitz/repos","events_url":"https://api.github.com/users/gilmoskowitz/events{/privacy}","received_events_url":"https://api.github.com/users/gilmoskowitz/received_events","type":"User","site_admin":false},"body":"The order of the `if-else-if` still looks wrong. If there's a redirect, no error will be reported so we'll `deleteLater` the QNetworkReply and unlock the mutex. We won't fall into the redirection handling code.","created_at":"2015-09-30T21:45:21Z","updated_at":"2015-09-30T21:45:21Z","html_url":"https://github.com/xtuple/qt-client/pull/880#discussion_r40856547","pull_request_url":"https://api.github.com/repos/xtuple/qt-client/pulls/880","_links":{"self":{"href":"https://api.github.com/repos/xtuple/qt-client/pulls/comments/40856547"},"html":{"href":"https://github.com/xtuple/qt-client/pull/880#discussion_r40856547"},"pull_request":{"href":"https://api.github.com/repos/xtuple/qt-client/pulls/880"}}},"pull_request":{"url":"https://api.github.com/repos/xtuple/qt-client/pulls/880","id":45570747,"html_url":"https://github.com/xtuple/qt-client/pull/880","diff_url":"https://github.com/xtuple/qt-client/pull/880.diff","patch_url":"https://github.com/xtuple/qt-client/pull/880.patch","issue_url":"https://api.github.com/repos/xtuple/qt-client/issues/880","number":880,"state":"open","locked":false,"title":"Fix redirect","user":{"login":"gpazo","id":2091498,"avatar_url":"https://avatars.githubusercontent.com/u/2091498?v=3","gravatar_id":"","url":"https://api.github.com/users/gpazo","html_url":"https://github.com/gpazo","followers_url":"https://api.github.com/users/gpazo/followers","following_url":"https://api.github.com/users/gpazo/following{/other_user}","gists_url":"https://api.github.com/users/gpazo/gists{/gist_id}","starred_url":"https://api.github.com/users/gpazo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gpazo/subscriptions","organizations_url":"https://api.github.com/users/gpazo/orgs","repos_url":"https://api.github.com/users/gpazo/repos","events_url":"https://api.github.com/users/gpazo/events{/privacy}","received_events_url":"https://api.github.com/users/gpazo/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-21T16:37:06Z","updated_at":"2015-09-30T21:45:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8d6e3daa41c36e38ac4d50abd14f440936afd070","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xtuple/qt-client/pulls/880/commits","review_comments_url":"https://api.github.com/repos/xtuple/qt-client/pulls/880/comments","review_comment_url":"https://api.github.com/repos/xtuple/qt-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xtuple/qt-client/issues/880/comments","statuses_url":"https://api.github.com/repos/xtuple/qt-client/statuses/6d2938bdd00bb57e5f09ba682b58267b5601bb4b","head":{"label":"gpazo:fixRedirect","ref":"fixRedirect","sha":"6d2938bdd00bb57e5f09ba682b58267b5601bb4b","user":{"login":"gpazo","id":2091498,"avatar_url":"https://avatars.githubusercontent.com/u/2091498?v=3","gravatar_id":"","url":"https://api.github.com/users/gpazo","html_url":"https://github.com/gpazo","followers_url":"https://api.github.com/users/gpazo/followers","following_url":"https://api.github.com/users/gpazo/following{/other_user}","gists_url":"https://api.github.com/users/gpazo/gists{/gist_id}","starred_url":"https://api.github.com/users/gpazo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gpazo/subscriptions","organizations_url":"https://api.github.com/users/gpazo/orgs","repos_url":"https://api.github.com/users/gpazo/repos","events_url":"https://api.github.com/users/gpazo/events{/privacy}","received_events_url":"https://api.github.com/users/gpazo/received_events","type":"User","site_admin":false},"repo":{"id":10646363,"name":"qt-client","full_name":"gpazo/qt-client","owner":{"login":"gpazo","id":2091498,"avatar_url":"https://avatars.githubusercontent.com/u/2091498?v=3","gravatar_id":"","url":"https://api.github.com/users/gpazo","html_url":"https://github.com/gpazo","followers_url":"https://api.github.com/users/gpazo/followers","following_url":"https://api.github.com/users/gpazo/following{/other_user}","gists_url":"https://api.github.com/users/gpazo/gists{/gist_id}","starred_url":"https://api.github.com/users/gpazo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gpazo/subscriptions","organizations_url":"https://api.github.com/users/gpazo/orgs","repos_url":"https://api.github.com/users/gpazo/repos","events_url":"https://api.github.com/users/gpazo/events{/privacy}","received_events_url":"https://api.github.com/users/gpazo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gpazo/qt-client","description":"Desktop Client and Database","fork":true,"url":"https://api.github.com/repos/gpazo/qt-client","forks_url":"https://api.github.com/repos/gpazo/qt-client/forks","keys_url":"https://api.github.com/repos/gpazo/qt-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gpazo/qt-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gpazo/qt-client/teams","hooks_url":"https://api.github.com/repos/gpazo/qt-client/hooks","issue_events_url":"https://api.github.com/repos/gpazo/qt-client/issues/events{/number}","events_url":"https://api.github.com/repos/gpazo/qt-client/events","assignees_url":"https://api.github.com/repos/gpazo/qt-client/assignees{/user}","branches_url":"https://api.github.com/repos/gpazo/qt-client/branches{/branch}","tags_url":"https://api.github.com/repos/gpazo/qt-client/tags","blobs_url":"https://api.github.com/repos/gpazo/qt-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gpazo/qt-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gpazo/qt-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/gpazo/qt-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gpazo/qt-client/statuses/{sha}","languages_url":"https://api.github.com/repos/gpazo/qt-client/languages","stargazers_url":"https://api.github.com/repos/gpazo/qt-client/stargazers","contributors_url":"https://api.github.com/repos/gpazo/qt-client/contributors","subscribers_url":"https://api.github.com/repos/gpazo/qt-client/subscribers","subscription_url":"https://api.github.com/repos/gpazo/qt-client/subscription","commits_url":"https://api.github.com/repos/gpazo/qt-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/gpazo/qt-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/gpazo/qt-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/gpazo/qt-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/gpazo/qt-client/contents/{+path}","compare_url":"https://api.github.com/repos/gpazo/qt-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gpazo/qt-client/merges","archive_url":"https://api.github.com/repos/gpazo/qt-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gpazo/qt-client/downloads","issues_url":"https://api.github.com/repos/gpazo/qt-client/issues{/number}","pulls_url":"https://api.github.com/repos/gpazo/qt-client/pulls{/number}","milestones_url":"https://api.github.com/repos/gpazo/qt-client/milestones{/number}","notifications_url":"https://api.github.com/repos/gpazo/qt-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gpazo/qt-client/labels{/name}","releases_url":"https://api.github.com/repos/gpazo/qt-client/releases{/id}","created_at":"2013-06-12T15:55:14Z","updated_at":"2014-06-24T19:31:06Z","pushed_at":"2015-09-29T18:54:33Z","git_url":"git://github.com/gpazo/qt-client.git","ssh_url":"git@github.com:gpazo/qt-client.git","clone_url":"https://github.com/gpazo/qt-client.git","svn_url":"https://github.com/gpazo/qt-client","homepage":null,"size":74609,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xtuple:4_10_x","ref":"4_10_x","sha":"fb294f34ca9421b1c841d3d0cc781ee111a338f8","user":{"login":"xtuple","id":703922,"avatar_url":"https://avatars.githubusercontent.com/u/703922?v=3","gravatar_id":"","url":"https://api.github.com/users/xtuple","html_url":"https://github.com/xtuple","followers_url":"https://api.github.com/users/xtuple/followers","following_url":"https://api.github.com/users/xtuple/following{/other_user}","gists_url":"https://api.github.com/users/xtuple/gists{/gist_id}","starred_url":"https://api.github.com/users/xtuple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtuple/subscriptions","organizations_url":"https://api.github.com/users/xtuple/orgs","repos_url":"https://api.github.com/users/xtuple/repos","events_url":"https://api.github.com/users/xtuple/events{/privacy}","received_events_url":"https://api.github.com/users/xtuple/received_events","type":"Organization","site_admin":false},"repo":{"id":10383821,"name":"qt-client","full_name":"xtuple/qt-client","owner":{"login":"xtuple","id":703922,"avatar_url":"https://avatars.githubusercontent.com/u/703922?v=3","gravatar_id":"","url":"https://api.github.com/users/xtuple","html_url":"https://github.com/xtuple","followers_url":"https://api.github.com/users/xtuple/followers","following_url":"https://api.github.com/users/xtuple/following{/other_user}","gists_url":"https://api.github.com/users/xtuple/gists{/gist_id}","starred_url":"https://api.github.com/users/xtuple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtuple/subscriptions","organizations_url":"https://api.github.com/users/xtuple/orgs","repos_url":"https://api.github.com/users/xtuple/repos","events_url":"https://api.github.com/users/xtuple/events{/privacy}","received_events_url":"https://api.github.com/users/xtuple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xtuple/qt-client","description":"This repository contains the source code for the Desktop client. The Desktop client is built using the Qt framework for C++. The client can be extended or customized using JavaScript. This client is used by all editions of xTuple ERP.","fork":false,"url":"https://api.github.com/repos/xtuple/qt-client","forks_url":"https://api.github.com/repos/xtuple/qt-client/forks","keys_url":"https://api.github.com/repos/xtuple/qt-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xtuple/qt-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xtuple/qt-client/teams","hooks_url":"https://api.github.com/repos/xtuple/qt-client/hooks","issue_events_url":"https://api.github.com/repos/xtuple/qt-client/issues/events{/number}","events_url":"https://api.github.com/repos/xtuple/qt-client/events","assignees_url":"https://api.github.com/repos/xtuple/qt-client/assignees{/user}","branches_url":"https://api.github.com/repos/xtuple/qt-client/branches{/branch}","tags_url":"https://api.github.com/repos/xtuple/qt-client/tags","blobs_url":"https://api.github.com/repos/xtuple/qt-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xtuple/qt-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xtuple/qt-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/xtuple/qt-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xtuple/qt-client/statuses/{sha}","languages_url":"https://api.github.com/repos/xtuple/qt-client/languages","stargazers_url":"https://api.github.com/repos/xtuple/qt-client/stargazers","contributors_url":"https://api.github.com/repos/xtuple/qt-client/contributors","subscribers_url":"https://api.github.com/repos/xtuple/qt-client/subscribers","subscription_url":"https://api.github.com/repos/xtuple/qt-client/subscription","commits_url":"https://api.github.com/repos/xtuple/qt-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/xtuple/qt-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/xtuple/qt-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/xtuple/qt-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/xtuple/qt-client/contents/{+path}","compare_url":"https://api.github.com/repos/xtuple/qt-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xtuple/qt-client/merges","archive_url":"https://api.github.com/repos/xtuple/qt-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xtuple/qt-client/downloads","issues_url":"https://api.github.com/repos/xtuple/qt-client/issues{/number}","pulls_url":"https://api.github.com/repos/xtuple/qt-client/pulls{/number}","milestones_url":"https://api.github.com/repos/xtuple/qt-client/milestones{/number}","notifications_url":"https://api.github.com/repos/xtuple/qt-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xtuple/qt-client/labels{/name}","releases_url":"https://api.github.com/repos/xtuple/qt-client/releases{/id}","created_at":"2013-05-30T13:54:04Z","updated_at":"2015-09-28T11:12:22Z","pushed_at":"2015-09-30T21:35:54Z","git_url":"git://github.com/xtuple/qt-client.git","ssh_url":"git@github.com:xtuple/qt-client.git","clone_url":"https://github.com/xtuple/qt-client.git","svn_url":"https://github.com/xtuple/qt-client","homepage":"","size":110759,"stargazers_count":29,"watchers_count":29,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":108,"mirror_url":null,"open_issues_count":13,"forks":108,"open_issues":13,"watchers":29,"default_branch":"4_10_x"}},"_links":{"self":{"href":"https://api.github.com/repos/xtuple/qt-client/pulls/880"},"html":{"href":"https://github.com/xtuple/qt-client/pull/880"},"issue":{"href":"https://api.github.com/repos/xtuple/qt-client/issues/880"},"comments":{"href":"https://api.github.com/repos/xtuple/qt-client/issues/880/comments"},"review_comments":{"href":"https://api.github.com/repos/xtuple/qt-client/pulls/880/comments"},"review_comment":{"href":"https://api.github.com/repos/xtuple/qt-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xtuple/qt-client/pulls/880/commits"},"statuses":{"href":"https://api.github.com/repos/xtuple/qt-client/statuses/6d2938bdd00bb57e5f09ba682b58267b5601bb4b"}}}}