"Request Redirect" option in HttpClient shared resource works with GET but not with POST and PUT.

"Request Redirect" option in HttpClient shared resource works with GET but not with POST and PUT.

book

Article ID: KB0073247

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks -
Not Applicable -

Description

Resolution:
BW uses the Jakarta HttpClient libraries for HTTP component implementation. Jakarta httpclient libraries version 2.0.2 (used in BW 5.2.x) used to allow redirects for POST, the way it now works for GET. Starting with version 3.0.1 of these client libraries, they now allow only GET, not POST or PUT. For more detail, refer to  http://hc.apache.org/httpclient-3.x/redirects.html.

++++++
This document provides a brief guide to custom handling of redirects with HttpClient.

There are a few types of redirect that HttpClient can not handle automatically either because they require user interaction, or they are outside of the scope of HttpClient or due to internal limitations. Currently HttpClient is unable to automatically handle redirects of entity enclosing methods such as POST and PUT. There can also be situations when manual processing of redirects is desired due to specific application requirements.

Handling redirects manually.

All response codes between 300 and 399 inclusive are redirect responses of some form. The most common redirect response codes are:

    301 Moved Permanently. HttpStatus.SC_MOVED_PERMANENTLY
    302 Moved Temporarily. HttpStatus.SC_MOVED_TEMPORARILY
    303 See Other. HttpStatus.SC_SEE_OTHER
    307 Temporary Redirect. HttpStatus.SC_TEMPORARY_REDIRECT
++++++

This issue is due to restrictions imposed by RFC 2616 in sections 10.3.2, 10.3.3 and 10.3.8. See "10.3.3 302 Found" in http://www.faqs.org/rfcs/rfc2616.html. The BW 6.3.x implementation of HttpcClient library uses client version 3.1 which is released post 3.0.1 and would have this limitation/restriction carried forward. As mentioned in the above document, HTTP client library specification clears that along with other 3xx codes, "302 Found" redirection cannot be handled with POST, PUT method and only works with GET method. Accept redirect option available in HTTP client resource enables the redirection when GET method is used. It will not work with the POST method. This restriction is imposed by the underlying library specification which TIBCO follows.

Issue/Introduction

"Request Redirect" option in HttpClient shared resource works with GET but not with POST and PUT.

Resolution

Conclusion: Since the limitations are imposed by third-party client libraries that BW uses, there is no out-of-box solution in BW to handle HTTP request redirection using POST or PUT methods.

Additional Information

http://hc.apache.org/httpclient-3.x/redirects.html
http://www.faqs.org/rfcs/rfc2616.html