luchomolina
luchomolina

Reputation: 1242

Typo on CakePHP's HttpSocket class?

I've been having issues when making HTTPS requests to servers via HttpSocket. HTTP requests work just fine. Checking the code of that class, I noticed the following piece starting on line 272 in HttpSocket. I'm on the latest 2.04 stable version, btw.

if (is_array($this->request['header'])) { 
    if (!empty($this->request['cookies'])) {
        $cookies = $this->buildCookies($this->request['cookies']);
    }
    $schema = '';
    $port = 0;
    if (isset($this->request['uri']['schema'])) {
        $schema = $this->request['uri']['schema'];
    }
    if (isset($this->request['uri']['port'])) {
        $port = $this->request['uri']['port'];
    }
    if (
        ($schema === 'http' && $port != 80) ||
        ($schema === 'https' && $port != 443) ||
        ($port != 80 && $port != 443)
    ) {
        $Host .= ':' . $port;
    }
    $this->request['header'] = array_merge(compact('Host'), $this->request['header']);
}

As far as I know, the request array never has a schema key, although it does have a scheme key, as seen here. It's interesting that it seems that the code has been like since version 1.0 and I couldn't find anything about it on the web. I also changed the letter, just to see if my code worked, but it caused warnings and notices. So... am I missing something?

I wanted to run it by experts, before I started digging deeper into the code. Any help or clarification will be appreciated.

Thanks.

Upvotes: 1

Views: 431

Answers (1)

mark
mark

Reputation: 21743

English is not my first language But from my understanding of sources like http://www.englishforums.com/English/SchemaVsScheme/jkwmw/post.htm and http://forum.wordreference.com/showthread.php?t=711283&langid=3 as well as http://www.answers.com/topic/scheme / http://www.answers.com/topic/schema it is indeed a typo.

It should probably be "scheme" because it is not a graphical or "visible" representation but a logical way of applying sth. Also the complete framework uses scheme everywhere regarding urls and schema regarding DB table representation.

I opened a ticket: http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/2345-typo-in-httpsocket-class

Upvotes: 1

Related Questions