Spring Framework
  1. Spring Framework
  2. SPR-7938

HttpClientErrorException should provide access to response headers

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 3.2 M2
    • Component/s: Web
    • Last commented by a User:
      false

      Description

      It would be good if HttpClientErrorException would not only provide access to the response body but also to response headers,

        Activity

        Hide
        Arjen Poutsma added a comment -

        Moved to SPR.

        Show
        Arjen Poutsma added a comment - Moved to SPR.
        Show
        Scott Andrews added a comment - https://github.com/SpringSource/spring-framework/pull/86
        Hide
        Dave Syer added a comment -

        I'm not sure if anyone tested this in a live system, but there is likely to be a nasty problem waiting for anyone using it out of the box. I think that the default implementation of HttpClientResponse (the JDK one) barfs if you try and get the headers from an error response, or even a non-OK one in my experience. It might be a good idea to be defensive about this line:

        HttpHeaders headers = response.getHeaders();
        

        Wrap it in a try/catch or something?

        Show
        Dave Syer added a comment - I'm not sure if anyone tested this in a live system, but there is likely to be a nasty problem waiting for anyone using it out of the box. I think that the default implementation of HttpClientResponse (the JDK one) barfs if you try and get the headers from an error response, or even a non-OK one in my experience. It might be a good idea to be defensive about this line: HttpHeaders headers = response.getHeaders(); Wrap it in a try/catch or something?
        Hide
        Chris Beams added a comment -

        Thanks for the heads-up, Dave. Scott, can you follow up and look into this?

        Show
        Chris Beams added a comment - Thanks for the heads-up, Dave. Scott, can you follow up and look into this?
        Hide
        Scott Andrews added a comment -

        @Dave The change set didn't change the semantics on when or how the HttpHeaders are accessed. If there is an issue, it a preexisting bug.

        Show
        Scott Andrews added a comment - @Dave The change set didn't change the semantics on when or how the HttpHeaders are accessed. If there is an issue, it a preexisting bug.
        Hide
        Rossen Stoyanchev added a comment -

        If I'm not mistaken the issue is specifically for a 401 response? SPR-9367

        Show
        Rossen Stoyanchev added a comment - If I'm not mistaken the issue is specifically for a 401 response? SPR-9367

          People

          • Assignee:
            Chris Beams
            Reporter:
            Julian Reschke
            Last updater:
            Trevor Marshall
          • Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 46 weeks, 2 days ago

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - Not Specified
              Not Specified
              Logged:
              Time Spent - 0.25d
              0.25d