|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
URLRedirect |
« View previous topic :: View next topic » |
Author |
Message
|
paranoid221 |
Posted: Sun Jun 13, 2010 6:56 pm Post subject: URLRedirect |
|
|
 Centurion
Joined: 03 Apr 2006 Posts: 101 Location: USA
|
Greetings,
I started working on putting together an HTTP flow intended to serve as URLRedirect Service. Here is how it should work:
Enter http://localhost:7080/URLRedirect in a browser and hit GO.
Broker should respond in such a way that the user is taken to http://www.google.com
This is what I have done thus far.
httpInput node to kick off the flow. PathSuffix is set to /URLRedirect
httpInput node is connected to a compute node where I'm setting values for the HTTPReply header as follows:
Code: |
DECLARE CRLF CHAR CAST(X'0D0A' AS CHAR CCSID InputRoot.Properties.CodedCharSetId);
SET OutputRoot.HTTPReplyHeader.Status = 'HTTP/1.1 301 Moved Permanently' || CRLF;
SET OutputRoot.HTTPReplyHeader.Location = 'www.google.com';
SET OutputRoot.HTTPReplyHeader."Content-Type" = 'text/html' || CRLF;
|
Compute node is connected to a HTTPReply node where I have unchecked the 'Generate default HTTP headers from reply or response'.
When I tested this, all I get in the browser is
I used HTTPSpy and HTTPInterceptor tools to watch how the headers are being populated and this is what I see:
Code: |
HTTP RESPONSE
----------------------
HTTP/1.1 200 OK
Status: HTTP/1.1 301 Moved Permanently
Content-Length: 73
Date: Mon, 14 Jun 2010 02:51:54 GMT
Server: Apache-Coyote/1.1
Via: 1.1 HttpSpy
|
I have also tried populating the HTTPResponse header with similar values as I did for HTTPReply header above. I did read in the infocenter that values for HTTPResponse header are non-editable but I thought what the heck let me try. The result was the same.
Next, I have gone through some knowledge base on HTTP protocol standard and status codes and modified my code to replace "Status" field with "Status-Line". Tested again and no change in the result.
Wondering if someone here can offer some insight into what I'm doing wrong and point me in the right direction.
Thanks in advance _________________ LIFE is a series of complex calculations, somewhere multiplied by ZERO. |
|
Back to top |
|
 |
paranoid221 |
Posted: Sun Jun 13, 2010 7:55 pm Post subject: |
|
|
 Centurion
Joined: 03 Apr 2006 Posts: 101 Location: USA
|
I found the solution to my problem. Will do some rigorous testing and update the thread with the solution. Stay Tuned. _________________ LIFE is a series of complex calculations, somewhere multiplied by ZERO. |
|
Back to top |
|
 |
paranoid221 |
Posted: Mon Jun 14, 2010 12:24 am Post subject: |
|
|
 Centurion
Joined: 03 Apr 2006 Posts: 101 Location: USA
|
For the benefit of others who may in future work on this type of framework:
To get this working I used the local environment overrides to reset the http status code. Inside the compute node before the HTTPReply node, these are the only 3 lines of code I have at this point -
Code: |
SET OutputLocalEnvironment.Destination.HTTP.ReplyStatusCode = '301';
SET OutputRoot.HTTPReplyHeader.Location = 'http://www.google.com';
SET OutputRoot.HTTPReplyHeader."Content-Type" = 'text/html';
|
Works as expected and my requirements are fulfilled. I went a step further and started playing around by using other http redirect codes as outlined in the HTTP protocol spec just to see what the HTTP headers look like when the client gets redirected.
301:
The browser gets redirected to google like I needed but the HTTP header doesnot contain the code 301 anywhere. In fact I see an HTTP/1.1 200 OK.
302: Same as above
307:
The first time I tested with this status code, I did see the 307 temporary redirect in the http response headers. However, after playing with other status codes I changed my code back to using 307 and tested again but this time the header doesn't show the 307 anymore. I see 200 OK instead.
I guess it has something to do with browser cache but I'll leave all that research and explanation for some other day.
But I was glad to get this working and make a good headstart for the week ahead. _________________ LIFE is a series of complex calculations, somewhere multiplied by ZERO. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|