CURL Returns Stale Results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
buttsp
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 9:17 am

CURL Returns Stale Results

Post by buttsp »

Hi,
Actually my problem is that When i make a CURL request to a back-end server running under Tomcat, I get the response(xml) and that's fine, but on my 2nd, 3rd and subsequent requests the CURL response (xml) is the same, where it shouldn't be.

For testing this problem I made a same request to the BE Tomcat server manually through the Browser (i.e. without CURL) and there it works fine. That is the back-end server returns modified results on each subsequent request. My subsequest requests just changing the sorting criteria attribute in the URL and on the basis of which tomcat is returning different results.

So could anybody pls help me in solving this problem.

thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

posting your code may help us help you.
buttsp
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 9:17 am

Post by buttsp »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

// init curl
		$churl = curl_init();

		//CURLOPT_HEADER
		curl_setopt($churl, CURLOPT_HTTPHEADER, $this->m_header);
		curl_setopt($churl, CURLOPT_HEADER, TRUE);

		// set URL
		curl_setopt($churl, CURLOPT_URL, $this->m_requestUrl);
				
		// Write result to variable
		curl_setopt($churl, CURLOPT_RETURNTRANSFER, TRUE);

		// Set timeout
		if ($this->m_timeout)
		{
			curl_setopt($churl, CURLOPT_TIMEOUT, $this->m_timeout);
			//curl_setopt($churl, CURLOPT_TIMEOUT, 3);
		}

		// set Proxy
		if ($this->m_curlProxy)
		{
			curl_setopt($churl, CURLOPT_PROXY, $this->m_curlProxy);
		}

		//curl_setopt($churl, CURLOPT_FRESH_CONNECT, TRUE); 
		//curl_setopt($churl, CURLOPT_CONNECTTIMEOUT, 0);


		// write content in $doc
		$response = curl_exec($churl);

		// close connection
		curl_close($churl);

Code: Select all

URL: http://slycl1158.st1.spray.net:8080/travelsearch10/SearchGateway?command=getResults&startIndex=1&noOfRecords=0&sortBy=1
URL: http://slycl1158.st1.spray.net:8080/travelsearch10/SearchGateway?command=getResults&startIndex=1&noOfRecords=0&sortBy=2
..3, 4

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you going through the proxy mentioned in the snippet?
buttsp
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 9:17 am

Post by buttsp »

No I'm sorry that was just a null value. I have just commented it but still the problem is the same.

No Proxy ..

Code: Select all

//		// set Proxy
//		if ($this->m_curlProxy)
//		{
//			curl_setopt($churl, CURLOPT_PROXY, $this->m_curlProxy);
//		}
Post Reply