Index: ClientSide.tcl ================================================================== --- ClientSide.tcl +++ ClientSide.tcl @@ -44,13 +44,15 @@ package require tdom 0.8 package require http 2 package require log package require uri -catch { +if {[catch { package require tls http::register https 443 [list ::tls::socket -ssl2 no -ssl3 no -tls1 yes] +} err]} { + log::log warning "No https support: $err" } package provide WS::Client 2.3.8 namespace eval ::WS::Client { @@ -920,10 +922,20 @@ set token [::WS::Utils::geturl_followRedirects $url -headers [string map {\{ \" \} \"} $headers]] } else { set token [::WS::Utils::geturl_followRedirects $url] } ::http::wait $token + if {![string equal [::http::status $token] ok] || + [::http::ncode $token] != 200} { + set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] + set errorInfo [FormatHTTPError $token] + ::http::cleanup $token + return \ + -code error \ + -errorcode $errorCode \ + $errorInfo + } set wsdlInfo [ParseWsdl [::http::data $token] -headers [string map {\{ \" \} \"} $headers] -serviceAlias $serviceAlias] ::http::cleanup $token } default { return \ @@ -1292,14 +1304,11 @@ ::log::log info "\nReceived: $body" if {![string equal [::http::status $token] ok] || ([::http::ncode $token] != 200 && [string equal $body {}])} { set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] set errorInfo {} - set results [::http::error $token] - if {[string equal $results {}] && [string equal [::http::status $token] ok]} { - set results [::http::code $token] - } + set results [FormatHTTPError $token] set hadError 1 } else { set hadError 0 set results [::http::data $token] } @@ -1441,11 +1450,11 @@ set errorInfo $::errorInfo } } } elseif {![string equal $httpStatus ok] || [::http::ncode $token] != 200} { ::log::log debug "\tHTTP error [array get $token]" - set results [::http::error $token] + set results [FormatHTTPError $token] set errorCode [list WSCLIENT HTTPERROR [::http::code $token]] set errorInfo {} set hadError 1 } else { set body [::http::data $token] @@ -1477,10 +1486,59 @@ ::log::log debug "Leaving ::WS::Client::DoCall with {$results}" return $results } } + +########################################################################### +# +# Public Procedure Header - as this procedure is modified, please be sure +# that you update this header block. Thanks. +# +#>>BEGIN PUBLIC<< +# +# Procedure Name : ::WS::Client::FormatHTTPError +# +# Description : Format error after a http::geturl failure. +# A failure consists wether in the HTTP return code unequal to 200 +# or in the status equal "error". Status "timeout" is untreated, as this +# http feature is not used in the package. +# +# Arguments : +# tolken - tolken of the http::geturl request +# +# Returns : +# Error message +# +# Side-Effects : None +# +# Pre-requisite Conditions : HTTP failure must be present +# +# Original Author : Harald Oehlmann +# +#>>END PUBLIC<< +# +# Maintenance History - as this file is modified, please be sure that you +# update this segment of the file header block by +# adding a complete entry at the bottom of the list. +# +# Version Date Programmer Comments / Changes / Reasons +# ------- ---------- ---------- ------------------------------------------- +# 1 06/02/2015 H.Oehlmann Initial version +# +# +########################################################################### +proc ::WS::Client::FormatHTTPError {token} { + if {[string equal [::http::status $token] ok]} { + if {[::http::size $token] == 0} { + return "HTTP failure socket closed" + } + return "HTTP failure code [::http::ncode $token]" + } else { + return "HTTP error: [::http::error $token]" + } +} ########################################################################### # # Public Procedure Header - as this procedure is modified, please be sure # that you update this header block. Thanks. @@ -1814,11 +1872,11 @@ ::log::log info "\nReceived: $body" if {![string equal [::http::status $token] ok] || ([::http::ncode $token] != 200 && [string equal $body {}])} { set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] set hadError 1 - set errorInfo [::http::error $token] + set errorInfo [FormatHTTPError $token] } else { SaveAndSetOptions $serviceName if {[catch {set hadError [catch {parseResults $serviceName $operationName $body} results]} err]} { RestoreSavedOptions $serviceName return -code error -errorcode $::errorCode -errorinfo $::errorInfo $err @@ -3164,11 +3222,11 @@ set body [::http::data $token] if {![string equal [::http::status $token] ok] || ([::http::ncode $token] != 200 && [string equal $body {}])} { set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] set errorInfo {} - set results [::http::error $token] + set results [FormatHTTPError $token] set hadError 1 } else { set hadError 0 set results [::http::data $token] } @@ -3292,11 +3350,11 @@ set hadError 0 set results {} if {![string equal $httpStatus ok] || ([::http::ncode $token] != 200 && [string equal $body {}])} { ::log::log debug "\tHTTP error [array get $token]" - set results [::http::error $token] + set results [FormatHTTPError $token] set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] set errorInfo {} set hadError 1 } else { SaveAndSetOptions $serviceName @@ -3699,11 +3757,11 @@ ::log::log info "\nReceived: $body" if {![string equal [::http::status $token] ok] || ([::http::ncode $token] != 200 && [string equal $body {}])} { set errorCode [list WS CLIENT HTTPERROR [::http::code $token]] set hadError 1 - set errorInfo [::http::error $token] + set errorInfo [FormatHTTPError $token] } else { SaveAndSetOptions $serviceName if {[catch {set hadError [catch {parseRestResults $serviceName $objectName $operationName $body} results]} err]} { RestoreSavedOptions $serviceName return -code error -errorcode $::errorCode -errorinfo $::errorInfo $err Index: Utilities.tcl ================================================================== --- Utilities.tcl +++ Utilities.tcl @@ -4561,12 +4561,10 @@ set finalUrlDir [string range $finalUrl 0 [expr {$lastPos - 1}]] ::log::log debug "initialUrlDir = $initialUrlDir, finalUrlDir = $finalUrlDir" set ::WS::Utils::redirectArray($initialUrlDir) $finalUrlDir } return $token - } elseif {![string match {20[1237]} $ncode]} { - return $token } array set meta [set ${token}(meta)] if {![info exist meta(Location)]} { return $token }