refreshing the token if HTTP 401 is returned (#83)

pull/40/head
Nestal Wan 2012-07-23 16:00:21 +08:00
parent 3acd25cb55
commit 51e42914f3
2 changed files with 21 additions and 2 deletions

11
README
View File

@ -1,4 +1,4 @@
Grive 0.2.0
Grive 0.3.0
9 June 2012
http://www.lbreda.com/grive/
@ -14,7 +14,6 @@ There are a few things that Grive does not do at the moment:
- wait for changes in file system to occur and upload. A sync is only performed when you run Grive.
- symbolic links support
- support for Google documents
- support for files >2GB
Of course these will be added in the future, possibly the next release.
@ -48,3 +47,11 @@ current directory. It will also start downloading files from your Google Drive t
your current directory.
Enjoy!
Version History:
Grive v0.3: Bug fix release
Fixed bugs:
#93: missing reference count increment in one of the Json constructors
#82: retry for HTTP error 500 & 503
#77: Fixed a bug where grive crashed on the first run.

View File

@ -125,6 +125,7 @@ std::string AuthAgent::Unescape( const std::string& str )
bool AuthAgent::CheckRetry( long response )
{
// HTTP 500 and 503 should be temperory. just wait a bit and retry
if ( response == 500 || response == 503 )
{
Log( "resquest failed due to temperory error: %1%. retrying in 5 seconds",
@ -133,6 +134,17 @@ bool AuthAgent::CheckRetry( long response )
os::Sleep( 5 ) ;
return true ;
}
// HTTP 401 Unauthorized. the auth token has been expired. refresh it
else if ( response == 401 )
{
Log( "resquest failed due to auth token expired: %1%. refreshing token",
response, log::warning ) ;
m_auth.Refresh() ;
return true ;
}
else
return false ;
}