curl-library
Re: Error codes from SFTP
Date: Thu, 11 Apr 2013 00:30:05 +0200
On Wed, Apr 10, 2013 at 08:08:59PM +0100, Sam Deane wrote:
> On the topic of SFTP, am I right in thinking that there's no way to retrieve the error code from an SFTP quote command that has failed?
>
> It seems that the error string returned by sftp_libssh2_strerror is output, but not the code itself.
>
> It seems a little bit fiddly to have to parse the strings to figure out the error, so I was wondering if the code can be returned in data->info.httpCode.
That's what's returned by CURLINFO_RESPONSE_CODE, which is already used for
non-HTTP protocols, so it sounds like a reasonable extension to me. Please also
document this use in curl_easy_getinfo.3 Ideally, the response code for all
SFTP operations would be stored, not just failures in quoted commands. And
httpcode must be 0 in all cases when the command succeeds.
> I've done a little experimental hack to try this, and it seems to work ok, but I wondered if there's something I'm missing? A slight abuse of the httpCode field perhaps - but it doesn't appear to be used for anything else with SFTP.
>
> Have enclosed a small patch illustrating what I mean. It's probably in the wrong format (sorry), but I can clean it up and send you a proper patch if you think it's a sensible approach.
The patch format looks fine to me.
> + Curl_safefree(sshc->quote_path1);
> + if (free2)
> + Curl_safefree(sshc->quote_path2);
sshc->quote_path2 should be NULL whenever it's not used, and it always needs to
be freed whenever it's non-NULL, so you should be able to remove free2 altogether
and always call Curl_safefree on it.
>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-11