Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

cfhttp + redirect not working

Posted on 2004-10-15
10
Medium Priority
?
1,285 Views
Last Modified: 2013-12-24
Hi,

  I am using cfhttp with the "redirect=yes" attribute.  The Responheader DOES return a location AND a 302 statuscode.  However, it is not redirecting.  I am using CFMX 6.0 on Windows.  

  All I am trying to do is submit some info to a site (which is working), and then it normally redirects you to another page using the values from the cookies that were set.  So if there is any way to get the redirect working OR if I can use cfhttp off of the first cfhttp, than that would work as well.

Thanks
Ben
0
Comment
Question by:bptacek
  • 5
  • 5
10 Comments
 

Author Comment

by:bptacek
ID: 12320689
Here is my CFDUMP of CFHTTP:
=============================================
Charset        ISO8859_1
Filecontent       <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Header       HTTP/1.1 302 Found Date: Fri, 15 Oct 2004 11:26:42 GMT Server: WebSphere Application Server/4.0 Set-Cookie: JSESSIONID=0000H5MASTBCAC0DIG3SOZ1Z5WA:tuhtsano;Path=/ Cache-Control: no-cache="set-cookie,set-cookie2" Expires: Thu, 01 Dec 1994 16:00:00 GMT Set-Cookie: acct=12313433;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r1c1=1;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r1c2=2;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r1c3=3;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r1c4=4;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r1c5=5;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r1c6=6;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r2c1=7;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r2c2=8;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r2c3=9;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r2c4=10;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r2c5=11;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: r2c6=12;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: sortBy=1;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT Set-Cookie: order=a;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT location: https://www.odfl.com/reports/ViewAttachment Keep-Alive: timeout=30, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html;charset=ISO8859_1 Content-Language: en content-length: 83
Mimetype       text/html
RawHeader       [undefined struct element]
Responseheader       
struct
Cache-Control       no-cache="set-cookie,set-cookie2"
Connection       Keep-Alive
Content-Language       en
Content-Type       text/html;charset=ISO8859_1
Date       Fri, 15 Oct 2004 11:26:42 GMT
Expires       Thu, 01 Dec 1994 16:00:00 GMT
Explanation       Found
Http_Version       HTTP/1.1
Keep-Alive       timeout=30, max=100
Server       WebSphere Application Server/4.0
Set-Cookie       
struct
1       JSESSIONID=0000H5MASTBCAC0DIG3SOZ1Z5WA:tuhtsano;Path=/
10       r2c2=8;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
11       r2c3=9;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
12       r2c4=10;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
13       r2c5=11;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
14       r2c6=12;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
15       sortBy=1;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
16       order=a;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
2       acct=12313433;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
3       r1c1=1;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
4       r1c2=2;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
5       r1c3=3;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
6       r1c4=4;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
7       r1c5=5;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
8       r1c6=6;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
9       r2c1=7;Domain=www.odfl.com;Expires=Sat, 15-Oct-2005 11:26:42 GMT
Status_Code       302
Transfer-Encoding       chunked
content-length       83
location       https://www.odfl.com/reports/ViewAttachment
Statuscode       -1 null
Text       YES
=============================================
0
 

Author Comment

by:bptacek
ID: 12320948
Just tried it on my CFMX 6.1 Linux box and the redirect works, however the page that it redirects to does not show proper page.  I wonder how I keep the same JSESSIONID or does the redirect keep this info when it goes to the next page?
0
 
LVL 5

Expert Comment

by:umbrae
ID: 12321046
coldfusions redirect attribute executes a request to the target of the redirection after the first request and handles the response of the second request like it was the result of the first request.

There are two ways you can possibly use the data you're looking for.

A: The cfhttp.fileContent variable may have the data you're looking for.

B: get rid of the 'redirect' attribute, and do a <cflocation url="#cfhttp.resonseHeader.location#">

Hope this Helps.

-Umbrae
0
[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

 

Author Comment

by:bptacek
ID: 12321249
Thank for the response umbrae.  I am aware of the cfhttp.responseHeader.location variable.  I am not trying to redirect it on the client side, but on the server side.  The redirected page will give me a TAB-Delimeted file that I need to be able to read and then automatically put the file into a db.  I know how to do the last part, but I need to be able to get to the redirected page to get the tabbed file first.  So I am looking for NO client intervention.

Thanks
Ben
0
 
LVL 5

Expert Comment

by:umbrae
ID: 12321351
I see, I believe I misunderstood your question to begin with. You might be able to execute another cfhttp with some 'cfhttpparam's in order to shove the cookies to the new request.

It might look something like this:

<CFHTTP url="#cfhttp.responseHeader.location#">
<CFHTTPPARAM type="Cookie" name="Cookie1" value="Cookie1Data">
<CFHTTPPARAM type="Cookie" name="Cookie2" value="Cookie2Data">
</CFHTTP>

Again, hope this helps, and hope I understood what you were looking for more clearly.

-Umbrae
0
 
LVL 5

Expert Comment

by:umbrae
ID: 12321358
As an addendum, you'd probably loop through the cookies array from your first cfhttp to pass the cookies most effectively with cfhttpparam.

-Umbrae
0
 

Author Comment

by:bptacek
ID: 12322572
Yeah, it seems like you are on the same page now :).  Anyways, I have tried passing the cookies manually.  However, there seems to be problems within problems here, because I tried to access the cookies by doing this:

CFHTTP.responseHeader.Set-Cookie

and

CFHTTP.responseHeader[Set-Cookie]

And I get an error that it can't find the "CFHTTP.responseHeader.Set" variable.  I assume this is the only way to loop through the cookies.  Plus, if I was able to get that "Set-Cookies", I am unsure as to how I would get the cookies and their values.  Is there a way to do this without parsing each line as a string?  Simple way to pull the cookie info out of the header?

Thanks
Ben
0
 
LVL 5

Expert Comment

by:umbrae
ID: 12322865
Try CFHTTP.responseHeader['Set-Cookie'], with the quotes. Also, as far as getting just the cookie data, I think a ReReplace(CFHTTP.responseHeader['Set-Cookie'][ArrayIndex],"([^;]*;.*)","\1;") would probably get the relevant data out of the string nicely.

-Umbrae
0
 
LVL 5

Accepted Solution

by:
umbrae earned 2000 total points
ID: 12322874
Whoops. Bug!

REReplace(CFHTTP.responseHeader['Set-Cookie'][ArrayIndex],"([^;]*;).*","\1;")

is correct. Sorry bout that.

-Umbrae
0
 

Author Comment

by:bptacek
ID: 12323272
Whoo hoo!!!! it works.... my biggest downfall is good old regexp.  I have to get familiar with it.

Thanks umbrae!

Here is my loop for the second cfhttp to grab the cookies, just in case anyone else comes along the same problem:
============================================
      <cfloop from="1" to="16" index="num">
            <cfset cookstring = REReplace(CFHTTP.responseHeader['Set-Cookie'][num],"([^;]*).*","\1")>
            <cfhttpparam type="cookie" name="#ListGetAt(cookstring,1,'=')#" value="#ListGetAt(cookstring,2,'=')#">
      </cfloop>
============================================
I used 16 because I wasn't sure how to do a count on CFHTTP.responseHeader['Set-Cookie'].  I got an error on ArrayLen, so I just counted the number of cookies from the first cfhttp.

Thanks again, here are your points.

Ben
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question