I'm using WSO2 Micro Integrator v1.2.0 Today i got a problem about HTTP status code 307/301. When destination endpoint response http code 307 or 301, micro integrator response immediately instead of follow redirects.
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "GET /destination_endpoint HTTP/1.1[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "Authorization: Basic Y3VjX3FsZHQ6Y3VjX3FsZHQ=[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "Accept: text/plain, application/json, application/x-jackson-smile, application/cbor, application/*+json, */*[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "Accept-Encoding: gzip,deflate[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "request_id: a16b98a9-8efa-4ff1-9060-83a82f9c4786[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "Host: destination_host[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "Connection: Keep-Alive[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2021-08-25 10:34:40,722] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 << "[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "HTTP/1.1 307 Temporary Redirect[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Server: nginx[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Date: Wed, 25 Aug 2021 04:32:43 GMT[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Content-Type: text/html[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Content-Length: 180[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Connection: keep-alive[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Set-Cookie: BPC=625112d03351499b4eb22e1d9286a164; path=/[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Location: https://redirects_url/[\r][\n]"
[2021-08-25 10:34:40,754] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "Strict-Transport-Security: max-age=15768000 always; includeSubdomains; preload[\r][\n]"
[2021-08-25 10:34:40,769] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "X-Frame-Options: DENY[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "X-Content-Type-Options: nosniff[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "<html>[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "<head><title>307 Temporary Redirect</title></head>[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "<body bgcolor="white">[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "<center><h1>307 Temporary Redirect</h1></center>[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "<hr><center>nginx</center>[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "</body>[\r][\n]"
[2021-08-25 10:34:40,785] DEBUG {wire} - HTTPS-Sender I/O dispatcher-2 >> "</html>[\r][\n]"
I searched everything on internet but still not have any solution for automatically follow redirects in micro integrator.
Anyone know how to config wso2 micro integrator automatically follow redirects with http code 307 or 301?
By default, it does not handle the redirection. One option is to handle that in the micro integrator by looking at the HTTP code.
<filter source="$axis2:HTTP_SC" regex="301">
<then>
<log level="custom">
<property name="----Working on 301--------" value="TRUE"/>
</log>
<property name="locationvalue" expression="$trp:Location"/>
// call the endpoint in the location header.
</then>
<else>
<log level="custom">
<property name="---------------respose----------------------" value="Execute other scenarios"/>
</log>
</else>
</filter>
Please refer - https://ei.docs.wso2.com/en/7.2.0/micro-integrator/use-cases/examples/routing_examples/routing_based_on_headers/