patches from richard: fix typo, more robust proxy error checking

This commit is contained in:
Damien Elmes 2009-06-04 17:42:45 +09:00
parent d0be463cc6
commit e8fd6922a0
2 changed files with 21 additions and 2 deletions

View file

@ -71,8 +71,25 @@ class GetShared(QDialog):
self.parent.setProgressParent(None) self.parent.setProgressParent(None)
self.form.search.setFocus() self.form.search.setFocus()
if err: if err:
errorString = self.http.errorString()
else:
# double check ... make sure http status code was valid
# this is to counter bugs in handling proxy responses
respHeader = self.http.lastResponse()
if respHeader.isValid():
statusCode = respHeader.statusCode()
if statusCode < 200 or statusCode >= 300:
err = True
errorString = respHeader.reasonPhrase()
else:
err = True
errorString = "Invalid HTTP header received!"
if err:
if self.parent.config['proxyHost']:
errorString += "\n" + _("Please check the proxy settings.")
showInfo(_("Unable to connect to server.") + "\n" + showInfo(_("Unable to connect to server.") + "\n" +
self.http.errorString(), parent=self) errorString, parent=self)
self.close() self.close()
return return
data = self.http.readAll() data = self.http.readAll()

View file

@ -1956,6 +1956,8 @@ it to your friends.
msg = _("""\ msg = _("""\
<h1>Sync Failed</h1> <h1>Sync Failed</h1>
Couldn't contact Anki Online. Please check your internet connection.""") Couldn't contact Anki Online. Please check your internet connection.""")
if self.config['proxyHost']:
msg += _(" Also check your proxy settings.")
if self.config['syncInMsgBox']: if self.config['syncInMsgBox']:
ui.utils.showWarning(msg) ui.utils.showWarning(msg)
else: else:
@ -2592,7 +2594,7 @@ Consider backing up your media directory first."""))
proxy.setPort(self.config['proxyPort']) proxy.setPort(self.config['proxyPort'])
if self.config['proxyUser']: if self.config['proxyUser']:
proxy.setUser(self.config['proxyUser']) proxy.setUser(self.config['proxyUser'])
proxy.setPass(self.config['proxyPass']) proxy.setPassword(self.config['proxyPass'])
QNetworkProxy.setApplicationProxy(proxy) QNetworkProxy.setApplicationProxy(proxy)
# python # python
proxy = "http://" proxy = "http://"