Page 1 of 2
Zend: WTF
Posted: Wed Aug 23, 2006 10:26 pm
by alex.barylski
Code: Select all
$http = new Zend_Http_Client();
// Set the URI to a POST data processor
$http->setUri('http://localhost/xampp/?page=postad');
$http->setHeaders(array('Location: http://localhost/xampp/?page=post'));
// ... $postData is initialized properly from the examples in Zend
$http->post($postData); // Execute HTTP request and redirect
Anybody care to tell me why the above code wouldn't redirect? I'm missing something...and it's driving me nutts

Posted: Wed Aug 23, 2006 10:34 pm
by feyd
Http_Client is their browser class. Why would a browser send a server a Location header?

Posted: Wed Aug 23, 2006 10:41 pm
by alex.barylski
feyd wrote:Http_Client is their browser class. Why would a browser send a server a Location header?

So how would I send a script POST contents and then redirect to that script?
Basically:
index.php --> somescript.php --> index.php
Index.php has a form which is submitted to somescript.php which checks validity, etc and redirects back to index.php (POSTING data for persistence) if anything goes wrong to allow corrections???
Could I use this class and header()???
Cheers

Posted: Wed Aug 23, 2006 10:45 pm
by feyd
If I read their documentation correctly the posted-to page redirecting would be followed (under defaults) provided it was a header redirection.
Posted: Wed Aug 23, 2006 10:52 pm
by alex.barylski
feyd wrote:If I read their documentation correctly the posted-to page redirecting would be followed (under defaults) provided it was a header redirection.
I'm missing something...
http://framework.zend.com/manual/en/zen ... ttp.client
Where in that doc does it have an example of posted-to page???
edit: sorry dude...but i'm growing impatient...I wanted this to just work...not interested in d*cking aorund

Posted: Wed Aug 23, 2006 11:00 pm
by feyd
You didn't miss anything much, they don't have an example. The text I was referring to is:
Introduction wrote:Zend_Http_Client follows up to 5 HTTP redirections by default. To change this behavior, pass the maximum number of allowed redirections to the get() method.
That suggested to me that it would follow a redirection sent for any request. If it doesn't, I would consider the documentation misleading.
Posted: Thu Aug 24, 2006 8:32 am
by Ollie Saunders
$this->_redirect
Posted: Thu Aug 24, 2006 12:24 pm
by alex.barylski
ole wrote:$this->_redirect
By convention, it appears any members with leading underscore are protected or private which mean I can't access them as you've suggested...
Cheers
Posted: Thu Aug 24, 2006 12:30 pm
by Ollie Saunders
Code: Select all
class BlahControllers extends Zend_Controller_Action // i think that's what its called
{
public function someAction()
{
$this->_redirect('yay!');
}
}
ole is attempting to talk purely in php code 
Posted: Thu Aug 24, 2006 12:41 pm
by alex.barylski
I'm still lost...
For starters I'm not using any of the Zend classes except for Zend_Http_Client and it's required base class(es).
I'm posting data and need to redirect POST data back to the original script...
Posted: Thu Aug 24, 2006 12:58 pm
by alex.barylski
Apparently, what I'm trying to do is quite the hack show...
Basically, redirection in response to a POST has a lot of caveats

Posted: Thu Aug 24, 2006 2:56 pm
by Ollie Saunders
For starters I'm not using any of the Zend classes except for Zend_Http_Client and it's required base class(es).
Oh right, well then you'll have to do the redirect manually with header as per normal.
Anybody care to tell me why the above code wouldn't redirect?
Can you define exactly what you mean by that. Allow the Http_Client to accept a redirection and make a second request or redirect your code to another file?
Posted: Thu Aug 24, 2006 4:14 pm
by alex.barylski
I haven't tried, but I don't think a normal redirect would work...as I'm not redirecting perse, but rather posting the data back to the original FORM and redirecting back to the original FORM...
Emulating postback...
Not just, POST data to script, which is easy, but POST data to script & redirect
Using a normal redirect using header() would likely do something like:
1) Send POST data to original script
2) Redirect back to original script - but without post data
So the original script would be executed twice, where first it receives the POSTed data and then it's executed again but just displays the FORM empty...
I need to carry out the process concurrently so when the page is requested the POST data is displayed in the FORM elements...
Any ideas? I think I'm on the right track, but I'd love to hear a solution immediately and not have to wade through the RFC for HTTP and it's status codes...

Posted: Thu Aug 24, 2006 5:21 pm
by Ollie Saunders
Not just, POST data to script, which is easy, but POST data to script & redirect
Ah in which case you can forget everything I have said in this thread thus far. Oh and I don't know how to do that so sorry I can't help anymore.
Posted: Thu Aug 24, 2006 5:25 pm
by feyd
Hockey wrote:I need to carry out the process concurrently so when the page is requested the POST data is displayed in the FORM elements...
This bit doesn't make sense. Grammatically I can't figure out what specifically you mean.