From a9351aa0e6744cdb4c5b6ce426f3b394804677f2 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 2 Mar 2016 07:24:10 +0100 Subject: [PATCH 31/37] coverity: honor exception specs --- src/libcmis/sharepoint-session.cxx | 26 +++++++++++++++----------- src/libcmis/sharepoint-session.hxx | 2 ++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/libcmis/sharepoint-session.cxx b/src/libcmis/sharepoint-session.cxx index d19868b..5310f4e 100644 --- a/src/libcmis/sharepoint-session.cxx +++ b/src/libcmis/sharepoint-session.cxx @@ -379,7 +379,7 @@ libcmis::HttpResponsePtr SharePointSession::httpPutRequest( std::string url, } catch ( const CurlException& e ) { - fetchDigestCode( ); + fetchDigestCodeCurl( ); response = HttpSession::httpPutRequest( url, is, headers ); } return response; @@ -398,7 +398,7 @@ libcmis::HttpResponsePtr SharePointSession::httpPostRequest( const std::string& } catch ( const CurlException& e ) { - fetchDigestCode( ); + fetchDigestCodeCurl( ); response = HttpSession::httpPostRequest( url, is, contentType, redirect ); } return response; @@ -413,26 +413,30 @@ void SharePointSession::httpDeleteRequest( std::string url ) } catch ( const CurlException& e ) { - fetchDigestCode( ); + fetchDigestCodeCurl( ); HttpSession::httpDeleteRequest( url ); } } void SharePointSession::fetchDigestCode( ) throw ( libcmis::Exception ) +try +{ + fetchDigestCodeCurl( ); +} +catch ( const CurlException& e ) +{ + throw e.getCmisException( ); +} + +void SharePointSession::fetchDigestCodeCurl( ) + throw ( CurlException ) { istringstream is( "empty" ); libcmis::HttpResponsePtr response; // url = http://host/_api/contextinfo, first we remove the '/web' part string url = m_bindingUrl.substr( 0, m_bindingUrl.size( ) - 4 ) + "/contextinfo"; - try - { - response = HttpSession::httpPostRequest( url, is, "" ); - } - catch ( const CurlException& e ) - { - throw e.getCmisException( ); - } + response = HttpSession::httpPostRequest( url, is, "" ); string res = response->getStream( )->str( ); Json jsonRes = Json::parse( res ); m_digestCode = jsonRes["d"]["GetContextWebInformation"]["FormDigestValue"].toString( ); diff --git a/src/libcmis/sharepoint-session.hxx b/src/libcmis/sharepoint-session.hxx index de365c5..d11a5d5 100644 --- a/src/libcmis/sharepoint-session.hxx +++ b/src/libcmis/sharepoint-session.hxx @@ -95,6 +95,8 @@ class SharePointSession : public BaseSession private: SharePointSession( ); + void fetchDigestCodeCurl( ) + throw ( CurlException ); std::string m_digestCode; }; -- 2.5.0