Tcl Library Source Code

View Ticket
Login
Ticket UUID: 284fd715e4fc6d5d3cb8a0409647b5f09058513a
Title: Return $result on HTTP Error
Type: RFE Version: 1.0.1
Submitter: scorriere Created on: 2015-12-17 14:04:53
Subsystem: rest Assigned To: aku
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2016-03-03 06:25:40
Resolution: Accepted Closed By: aku
    Closed on: 2016-03-03 06:25:40
Description:
I am looking into using the rest package for testing our REST API.  For testing purposes, we will want to create error situations.  When the rest calls hit a non 2xx HTTP response, an error is returned.  The error message only contains the HTTP response code in the form of "HTTP <code>".

We would like to get the body($result) back with the response code.  Even though the return code specifies an error, there is useful data in the body of the response.
User Comments: aku added on 2016-03-03 06:25:40:

Fix merged, commit [9703590256]. Done.

And thank you for your patience.


scorriere added on 2016-03-02 16:02:39:
The changes look good to me.  I have tested in my environment.  I have had successful and error requests work appropriately with error-body unset and with error-body set.  I get the correct return in all 4 cases.

The code changes look good to me (Damn, I missed the httpCode thing when I wrote it).

Thanks for handling this aku!

aku added on 2016-03-02 05:48:47:

Fixed with commit [87b07c73c6].

**Note** The code generating the retList had a bug, for redirection errors the location information got lost. This part of the patch was rewritten. The rewrite also made use of the new httpCode variable. The original set it, and then made no use of it.

The change is currently on branch [rest-tkt-284fd715e4].

Please review the commit and my changes to the patch. Please get a tarball from the branch (*) and test that the changes actually work in your environment.

(Ad *) You must be logged in as anon to see the links for tarball or zip download in the info page for the commit.


scorriere added on 2016-02-16 15:20:41:
I forgot to mention that I opened a pull request for this feature.  Please see:
https://github.com/tcltk/tcllib/pull/6

scorriere added on 2015-12-17 19:56:20:
I took some more time to investigate this today.  I attempted to use callbacks to get the $result data along with the HTTP return code.  It appears that the _callback code uses a different callback if there is an HTTP error.  The body of the response is not passed to the callback, just the HTTP return code (And location if 302).