Skip to content

Commit 3a71894

Browse files
committed
Rnaming our HTTPLite classes to HTTP namespace.
1 parent da68403 commit 3a71894

14 files changed

Lines changed: 188 additions & 38 deletions

application/config/autoload.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public function __construct()
6767
'CodeIgniter\Benchmark\Timer' => BASEPATH.'Benchmark/Timer.php',
6868
'CodeIgniter\Benchmark\Iterator' => BASEPATH.'Benchmark/Iterator.php',
6969
'CodeIgniter\Config\BaseConfig' => BASEPATH.'Config/BaseConfig.php',
70-
'CodeIgniter\HTTPLite\Request' => BASEPATH.'HTTPLite/Request.php',
71-
'CodeIgniter\HTTPLite\IncomingRequest' => BASEPATH.'HTTPLite/IncomingRequest.php',
72-
'CodeIgniter\HTTPLite\RequestInterface' => BASEPATH.'HTTPLite/RequestInterface.php',
73-
'CodeIgniter\HTTPLite\URI' => BASEPATH.'HTTPLite/URI.php',
74-
'CodeIgniter\HTTPLite\Response' => BASEPATH.'HTTPLite/Response.php',
70+
'CodeIgniter\HTTP\Request' => BASEPATH.'HTTP/Request.php',
71+
'CodeIgniter\HTTP\IncomingRequest' => BASEPATH.'HTTP/IncomingRequest.php',
72+
'CodeIgniter\HTTP\RequestInterface' => BASEPATH.'HTTP/RequestInterface.php',
73+
'CodeIgniter\HTTP\URI' => BASEPATH.'HTTP/URI.php',
74+
'CodeIgniter\HTTP\Response' => BASEPATH.'HTTP/Response.php',
7575
'CodeIgniter\Debug\Exceptions' => BASEPATH.'Debug/Exceptions.php',
7676
'CodeIgniter\Router\RouteCollection' => BASEPATH.'Router/RouteCollection.php',
7777
'CodeIgniter\Router\RouteCollectionInterface' => BASEPATH.'Router/RouteCollectionInterface.php',

application/config/services.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ public function __construct()
4444
},
4545
'clirequest' => function ($di)
4646
{
47-
return new \CodeIgniter\HTTPLite\CLIRequest(
48-
new AppConfig(), new \CodeIgniter\HTTPLite\URI()
47+
return new \CodeIgniter\HTTP\CLIRequest(
48+
new AppConfig(), new \CodeIgniter\HTTP\URI()
4949
);
5050
},
5151
'request' => function ($di)
5252
{
53-
return new \CodeIgniter\HTTPLite\IncomingRequest(
54-
new AppConfig(), new \CodeIgniter\HTTPLite\URI()
53+
return new \CodeIgniter\HTTP\IncomingRequest(
54+
new AppConfig(), new \CodeIgniter\HTTP\URI()
5555
);
5656
},
57-
'uri' => '\CodeIgniter\HTTPLite\URI',
58-
'response' => '\CodeIgniter\HTTPLite\Response',
57+
'uri' => '\CodeIgniter\HTTP\URI',
58+
'response' => '\CodeIgniter\HTTP\Response',
5959

6060
// Your custom files can be added here.
6161
];

system/HTTP/CLIRequest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php namespace CodeIgniter\HTTP;
2+
3+
class CLIRequest {
4+
5+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CodeIgniter\HTTPLite;
1+
<?php namespace CodeIgniter\HTTP;
22

33
use App\Config\AppConfig;
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CodeIgniter\HTTPLite;
1+
<?php namespace CodeIgniter\HTTP;
22

33
/**
44
* Class OutgoingRequest
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CodeIgniter\HTTPLite;
1+
<?php namespace CodeIgniter\HTTP;
22

33
require_once 'system/Config/BaseConfig.php';
44
require_once 'application/config/AppConfig.php';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CodeIgniter\HTTPLite;
1+
<?php namespace CodeIgniter\HTTP;
22

33
use App\Config\AppConfig;
44

system/HTTP/Response.php

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php namespace CodeIgniter\HTTP;
2+
3+
class Response
4+
{
5+
protected static $statusCodes = [
6+
// 1xx: Informational
7+
100 => 'Continue',
8+
101 => 'Switching Protocols',
9+
102 => 'Processing', // http://www.iana.org/go/rfc2518
10+
11+
// 2xx: Success
12+
200 => 'OK',
13+
201 => 'Created',
14+
202 => 'Accepted',
15+
203 => 'Non-Authoritative Information', // 1.1
16+
204 => 'No Content',
17+
205 => 'Reset Content',
18+
206 => 'Partial Content',
19+
207 => 'Multi-Status', // http://www.iana.org/go/rfc4918
20+
208 => 'Already Reported', // http://www.iana.org/go/rfc5842
21+
226 => 'IM Used', // 1.1; http://www.ietf.org/rfc/rfc3229.txt
22+
23+
// 3xx: Redirection
24+
300 => 'Multiple Choices',
25+
301 => 'Moved Permanently',
26+
302 => 'Found', // Formerly 'Moved Temporarily'
27+
303 => 'See Other', // 1.1
28+
304 => 'Not Modified',
29+
305 => 'Use Proxy', // 1.1
30+
306 => 'Switch Proxy', // No longer used
31+
307 => 'Temporary Redirect', // 1.1
32+
308 => 'Permanent Redirect', // 1.1; Experimental; http://www.ietf.org/rfc/rfc7238.txt
33+
34+
// 4xx: Client error
35+
400 => 'Bad Request',
36+
401 => 'Unauthorized',
37+
402 => 'Payment Required',
38+
403 => 'Forbidden',
39+
404 => 'Not Found',
40+
405 => 'Method Not Allowed',
41+
406 => 'Not Acceptable',
42+
407 => 'Proxy Authentication Required',
43+
408 => 'Request Timeout',
44+
409 => 'Conflict',
45+
410 => 'Gone',
46+
411 => 'Length Required',
47+
412 => 'Precondition Failed',
48+
413 => 'Request Entity Too Large',
49+
414 => 'Request-URI Too Long',
50+
415 => 'Unsupported Media Type',
51+
416 => 'Requested Range Not Satisfiable',
52+
417 => 'Expectation Failed',
53+
418 => "I'm a teapot", // April's Fools joke; http://www.ietf.org/rfc/rfc2324.txt
54+
// 419 (Authentication Timeout) is a non-standard status code with unknown origin
55+
421 => 'Misdirected Request', // http://www.iana.org/go/rfc7540 Section 9.1.2
56+
422 => 'Unprocessable Entity', // http://www.iana.org/go/rfc4918
57+
423 => 'Locked', // http://www.iana.org/go/rfc4918
58+
424 => 'Failed Dependency', // http://www.iana.org/go/rfc4918
59+
426 => 'Upgrade Required',
60+
428 => 'Precondition Required', // 1.1; http://www.ietf.org/rfc/rfc6585.txt
61+
429 => 'Too Many Requests', // 1.1; http://www.ietf.org/rfc/rfc6585.txt
62+
431 => 'Request Header Fields Too Large', // 1.1; http://www.ietf.org/rfc/rfc6585.txt
63+
64+
// 5xx: Server error
65+
500 => 'Internal Server Error',
66+
501 => 'Not Implemented',
67+
502 => 'Bad Gateway',
68+
503 => 'Service Unavailable',
69+
504 => 'Gateway Timeout',
70+
505 => 'HTTP Version Not Supported',
71+
506 => 'Variant Also Negotiates', // 1.1; http://www.ietf.org/rfc/rfc2295.txt
72+
507 => 'Insufficient Storage', // http://www.iana.org/go/rfc4918
73+
508 => 'Loop Detected', // http://www.iana.org/go/rfc5842
74+
510 => 'Not Extended', // http://www.ietf.org/rfc/rfc2774.txt
75+
511 => 'Network Authentication Required' // http://www.ietf.org/rfc/rfc6585.txt
76+
];
77+
78+
/**
79+
* The current reason phrase for this response.
80+
* If null, will use the default provided for the status code.
81+
*
82+
* @var string
83+
*/
84+
protected $reason;
85+
86+
/**
87+
* The current status code for this response.
88+
*
89+
* @var int
90+
*/
91+
protected $statusCode = 200;
92+
93+
//--------------------------------------------------------------------
94+
95+
/**
96+
* Gets the response status code.
97+
*
98+
* The status code is a 3-digit integer result code of the server's attempt
99+
* to understand and satisfy the request.
100+
*
101+
* @return int Status code.
102+
*/
103+
public function statusCode(): int
104+
{
105+
return $this->statusCode;
106+
}
107+
108+
//--------------------------------------------------------------------
109+
110+
/**
111+
* Return an instance with the specified status code and, optionally, reason phrase.
112+
*
113+
* If no reason phrase is specified, will default recommended reason phrase for
114+
* the response's status code.
115+
*
116+
* @see http://tools.ietf.org/html/rfc7231#section-6
117+
* @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
118+
*
119+
* @param int $code The 3-digit integer result code to set.
120+
* @param string $reasonPhrase The reason phrase to use with the
121+
* provided status code; if none is provided, will
122+
* default to the IANA name.
123+
*
124+
* @return self
125+
* @throws \InvalidArgumentException For invalid status code arguments.
126+
*/
127+
public function setStatusCode(int $code, string $reason = ''): self
128+
{
129+
}
130+
131+
//--------------------------------------------------------------------
132+
133+
/**
134+
* Gets the response response phrase associated with the status code.
135+
*
136+
* @see http://tools.ietf.org/html/rfc7231#section-6
137+
* @see http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
138+
*
139+
* @return string
140+
*/
141+
public function reason(): string
142+
{
143+
if (empty($this->reason))
144+
{
145+
return ! empty($this->statusCode)
146+
? static::$statusCodes[$this->statusCode]
147+
: '';
148+
}
149+
150+
return $this->reason;
151+
}
152+
153+
//--------------------------------------------------------------------
154+
155+
156+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CodeIgniter\HTTPLite;
1+
<?php namespace CodeIgniter\HTTP;
22

33
class URI
44
{

system/HTTPLite/CLIRequest.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)