The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 06:12:07 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: webrequest class not cooperating  (Read 3628 times)
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« on: February 09, 2008, 07:30:21 PM »

For some reason using the webrequest class in the manner of my framework is not working. It does work on another site, on the same server, without my framework. Obviously its something with my framework but again, just not seeing it. It runs the execution, but nothing gets returned from the remote server. If i hit the same server using just this:
$xml = new SimpleXMLElement(file_get_contents($url));
it can grab the content.

application->scrapesomething gets called from my presentation page, but no need to show that.

debug output
Code:
simpleGet: Starts with [http://www.asu.edu]
Outbound Header:
GET  HTTP/1.1
Host: www.asu.edu
User-Agent:
Accept:
Accept-Language:
Accept-Encoding:
Accept-Charset:
Connection: close

Content-Type: text/html
Content-Length: 0

Default beforeExecute()
Execute: Starts
Execute: HostStr=[www.asu.edu] Port:80
Execute: PHP5 or greater, setting timeout of
Execute: Sending request
Execute: Request Sent
GetChunk: Starts
getChunk: Remote Timeout
handleProxyRetry()
Execute: Failed - Did not receive anything from remote host
handleFailure()
Default afterExecute()
simpleGet Failed
Array
(
)

My application class - stripped down
Code:
class application
{    
private function scrapesomething()
{
//Get the URLs to scrape
$url= "http://www.asu.edu";
$req = &$GLOBALS['webrequest']; //this is the global reference to the webrequest object instance in the presentation page.
                $req->debugMode = WRD_ECHO;
$req->method = 'GET'; //for some reason if i dont put this, it wont default to get, and it fails. clue?
$result = $req->simpleGet($url);
print_r($req->getHeaders());
       }
}

only thing that was added to perks webrequest class was this constructor to enable global access to a single object. (per my framework)
Code:
function __construct() {
if ($GLOBALS['webrequest'])
{
$GLOBALS['messages']->adderr('webrequest.class.php is being constructed more than once.');
}
else
{
$GLOBALS['webrequest'] = &$this;
}
    }
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #1 on: February 10, 2008, 07:51:57 PM »

I ran some more tests, such as instantiating the webrequest object from within the application->function.
still no worky. but the result from debug is different.

Code:
simpleGet: Starts with [http://www.mit.edu]
Outbound Header:
GET  HTTP/1.1
Host: www.mit.edu
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/417.9 (KHTML, like Gecko) Safari/417.8
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding:
Accept-Charset: ISO-8859-1,utf-8:q=0.7,*;q=0.7
Connection: close

Content-Type: text/html
Content-Length: 0

Default beforeExecute()
Execute: Starts
Execute: HostStr=[www.mit.edu] Port:80
Execute: PHP5 or greater, setting timeout of 30
Execute: Sending request
Execute: Request Sent
GetChunk: Starts
GetChunk: Received 2988
processHeaders: Starts
processHeaders: Result Code is
processHeaders: Array Follows
Array
(
)
Execute: Successful Retrieve
postProcess: Content length is 0
handleSuccess()
Default afterExecute()
Execute: Completes
simpleGet Failed
Array
(
)
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: February 11, 2008, 03:51:32 PM »

NB - how you're using it is unfamiliar to me so I'll try to ring you up later and get more symptoms and example source

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #3 on: February 11, 2008, 05:58:02 PM »

i dunno. my framework seems to be having issues. particularly the database class. My methodology of assigning each object to a global variable is not working. Weird behavior is afoot.

like doing a "select * from table where something=somethingelse limit 2" and then looping, actually processes 7 rows... LOL

conceptually I like my framework, but I have a feeling it just is too open to weirdness. Unless its just that Im not understanding php and its intricacies.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: February 12, 2008, 09:05:52 AM »

I've been wanting to talk to you re. "frameworks" in any case.

I've noticed something extremely similar about your's and my trajectories, moving from large compiled language IDEs into this new realm. The most important thing I can say is that I had a gorgeous, full featured capital-F Framework written in Kylix and Delphi that was the basis for all of my sites. It was the most efficient and best way to do things.

I wrote my first couple passes at a PHP-based framework the same way. It was lush and full, chock full of all kinds of mechanisms that I thought would really make my future PHP life better.

Now my framework (lowercase f) is more a loose confederation of includes than a large single code body. I notice as I get better and better with PHP (I'm in about 2.5 years now) that my code gets lighter, smaller, tighter and faster as I move away from my older notions of Framework into littler classes that I combine and retask more easily. Today, my backoffice framework, for example, LOOKS like it is a big managed app, but actually it's a bunch of pages that happen to work together. It is true that everything flows through a single script and my essentially page construction methodology is the same, but the code that does it is pretty light. My stock retail site script is only a couple hundred lines long now - my basic structure is pretty simple:

  • Create just a couple global objects like a db connection - but my db connection does not actually connect until it's required, so it's still pretty light
  • Check to make sure <whatever cached items [this] site needs> are loaded
  • Translate URL to taste
  • require() <the page file> defined by the URL. This page file will include the theme file if it requires it. A normal page will, a report page, for example, will not.
  • Some times the main script will do some output modification with the content[] array that is created by that whole mess. For example, retail sites may need prices changed to reflect the country of surfer origin - that's done in the main script because I don't want to have every page, the theme etc have to know what country the surfer is from.
  • echo implode(chr(10), $content);

I know you'll need to follow a trajectory and explorations at your own pace... just wanted to offer this a gear turner because you seem a bit frustrated by the complexity of it. I get it.


/p
« Last Edit: February 12, 2008, 09:08:49 AM by perkiset » Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #5 on: February 12, 2008, 11:47:15 AM »

I fully agree.
The main problem i am trying to tackle though is codebase-consistency. If i deploy custom apps to 5 different clients, all of which are built using the same framework, I can easily update security handling for example, by just dropping the new class class file into each site. In an ideal world, all my stuff would operate via RPC, but that is unrealistic with latency and such.

My framework is not complicated, and is only to provide the bare minimum of consistent functionalities that every single site i make has. Such as
database connectivity and SQL injection defense
access security both page level and inpage level
template management and display security (XSS defense)
messaging
general configuration class with site specific constants like database logins for example
helpers like a dateadd function.

thats really it. everything else is just piled into one giant ass application class.
The only reason is consistency.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #6 on: February 13, 2008, 04:35:16 PM »

thats really weird. my constructor to globalize the object actually prevents it from functioning. Im sure if i actually took some time to read though all your code I would realize why, but alas, I am a lazy bastard and just barreling through stuff for now. So pffft. moving onward and just using the class locally when needed.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: February 13, 2008, 06:03:44 PM »

Alas.
 ROFLMAO

Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #8 on: February 13, 2008, 06:13:41 PM »

You are just jealous of my mastery of archaic english.  Wink
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #9 on: February 13, 2008, 08:05:04 PM »

It's a fair cop.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!