7 changed files with 4554 additions and 618 deletions
-
2sapi/cli/config.m4
-
3sapi/cli/config.w32
-
1261sapi/cli/php_cli.c
-
2084sapi/cli/php_cli_server.c
-
38sapi/cli/php_cli_server.h
-
1602sapi/cli/php_http_parser.c
-
182sapi/cli/php_http_parser.h
1261
sapi/cli/php_cli.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2084
sapi/cli/php_cli_server.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,38 @@ |
|||||
|
/* |
||||
|
+----------------------------------------------------------------------+ |
||||
|
| PHP Version 5 | |
||||
|
+----------------------------------------------------------------------+ |
||||
|
| Copyright (c) 1997-2011 The PHP Group | |
||||
|
+----------------------------------------------------------------------+ |
||||
|
| This source file is subject to version 3.01 of the PHP license, | |
||||
|
| that is bundled with this package in the file LICENSE, and is | |
||||
|
| available through the world-wide-web at the following url: | |
||||
|
| http://www.php.net/license/3_01.txt | |
||||
|
| If you did not receive a copy of the PHP license and are unable to | |
||||
|
| obtain it through the world-wide-web, please send a note to | |
||||
|
| license@php.net so we can mail you a copy immediately. | |
||||
|
+----------------------------------------------------------------------+ |
||||
|
| Author: Moriyoshi Koizumi <moriyoshi@php.net> | |
||||
|
+----------------------------------------------------------------------+ |
||||
|
*/ |
||||
|
|
||||
|
/* $Id: php_cli.c 306938 2011-01-01 02:17:06Z felipe $ */ |
||||
|
|
||||
|
#ifndef PHP_CLI_SERVER_H |
||||
|
#define PHP_CLI_SERVER_H |
||||
|
|
||||
|
#include "SAPI.h" |
||||
|
|
||||
|
extern sapi_module_struct cli_server_sapi_module; |
||||
|
extern int do_cli_server(int argc, char **argv TSRMLS_DC); |
||||
|
|
||||
|
#endif /* PHP_CLI_SERVER_H */ |
||||
|
|
||||
|
/* |
||||
|
* Local variables: |
||||
|
* tab-width: 4 |
||||
|
* c-basic-offset: 4 |
||||
|
* End: |
||||
|
* vim600: noet sw=4 ts=4 fdm=marker |
||||
|
* vim<600: noet sw=4 ts=4 |
||||
|
*/ |
||||
1602
sapi/cli/php_http_parser.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,182 @@ |
|||||
|
/* Copyright 2009,2010 Ryan Dahl <ry@tinyclouds.org> |
||||
|
* |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to |
||||
|
* deal in the Software without restriction, including without limitation the |
||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
||||
|
* sell copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
||||
|
* IN THE SOFTWARE. |
||||
|
*/ |
||||
|
/* modified by Moriyoshi Koizumi <moriyoshi@php.net> to make it fit to PHP source tree. */ |
||||
|
#ifndef php_http_parser_h |
||||
|
#define php_http_parser_h |
||||
|
#ifdef __cplusplus |
||||
|
extern "C" { |
||||
|
#endif |
||||
|
|
||||
|
|
||||
|
#include <sys/types.h> |
||||
|
#if defined(_WIN32) && !defined(__MINGW32__) |
||||
|
typedef __int8 int8_t; |
||||
|
typedef unsigned __int8 uint8_t; |
||||
|
typedef __int16 int16_t; |
||||
|
typedef unsigned __int16 uint16_t; |
||||
|
typedef __int32 int32_t; |
||||
|
typedef unsigned __int32 uint32_t; |
||||
|
typedef __int64 int64_t; |
||||
|
typedef unsigned __int64 uint64_t; |
||||
|
|
||||
|
typedef unsigned int size_t; |
||||
|
typedef int ssize_t; |
||||
|
#else |
||||
|
#include <stdint.h> |
||||
|
#endif |
||||
|
|
||||
|
/* Compile with -DPHP_HTTP_PARSER_STRICT=0 to make less checks, but run |
||||
|
* faster |
||||
|
*/ |
||||
|
#ifndef PHP_HTTP_PARSER_STRICT |
||||
|
# define PHP_HTTP_PARSER_STRICT 1 |
||||
|
#else |
||||
|
# define PHP_HTTP_PARSER_STRICT 0 |
||||
|
#endif |
||||
|
|
||||
|
|
||||
|
/* Maximium header size allowed */ |
||||
|
#define PHP_HTTP_MAX_HEADER_SIZE (80*1024) |
||||
|
|
||||
|
|
||||
|
typedef struct php_http_parser php_http_parser; |
||||
|
typedef struct php_http_parser_settings php_http_parser_settings; |
||||
|
|
||||
|
|
||||
|
/* Callbacks should return non-zero to indicate an error. The parser will |
||||
|
* then halt execution. |
||||
|
* |
||||
|
* The one exception is on_headers_complete. In a PHP_HTTP_RESPONSE parser |
||||
|
* returning '1' from on_headers_complete will tell the parser that it |
||||
|
* should not expect a body. This is used when receiving a response to a |
||||
|
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding: |
||||
|
* chunked' headers that indicate the presence of a body. |
||||
|
* |
||||
|
* http_data_cb does not return data chunks. It will be call arbitrarally |
||||
|
* many times for each string. E.G. you might get 10 callbacks for "on_path" |
||||
|
* each providing just a few characters more data. |
||||
|
*/ |
||||
|
typedef int (*php_http_data_cb) (php_http_parser*, const char *at, size_t length); |
||||
|
typedef int (*php_http_cb) (php_http_parser*); |
||||
|
|
||||
|
|
||||
|
/* Request Methods */ |
||||
|
enum php_http_method |
||||
|
{ PHP_HTTP_DELETE = 0 |
||||
|
, PHP_HTTP_GET |
||||
|
, PHP_HTTP_HEAD |
||||
|
, PHP_HTTP_POST |
||||
|
, PHP_HTTP_PUT |
||||
|
/* pathological */ |
||||
|
, PHP_HTTP_CONNECT |
||||
|
, PHP_HTTP_OPTIONS |
||||
|
, PHP_HTTP_TRACE |
||||
|
/* webdav */ |
||||
|
, PHP_HTTP_COPY |
||||
|
, PHP_HTTP_LOCK |
||||
|
, PHP_HTTP_MKCOL |
||||
|
, PHP_HTTP_MOVE |
||||
|
, PHP_HTTP_PROPFIND |
||||
|
, PHP_HTTP_PROPPATCH |
||||
|
, PHP_HTTP_UNLOCK |
||||
|
/* subversion */ |
||||
|
, PHP_HTTP_REPORT |
||||
|
, PHP_HTTP_MKACTIVITY |
||||
|
, PHP_HTTP_CHECKOUT |
||||
|
, PHP_HTTP_MERGE |
||||
|
/* upnp */ |
||||
|
, PHP_HTTP_MSEARCH |
||||
|
, PHP_HTTP_NOTIFY |
||||
|
, PHP_HTTP_SUBSCRIBE |
||||
|
, PHP_HTTP_UNSUBSCRIBE |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
enum php_http_parser_type { PHP_HTTP_REQUEST, PHP_HTTP_RESPONSE, PHP_HTTP_BOTH }; |
||||
|
|
||||
|
|
||||
|
struct php_http_parser { |
||||
|
/** PRIVATE **/ |
||||
|
unsigned char type : 2; |
||||
|
unsigned char flags : 6; |
||||
|
unsigned char state; |
||||
|
unsigned char header_state; |
||||
|
unsigned char index; |
||||
|
|
||||
|
uint32_t nread; |
||||
|
int64_t content_length; |
||||
|
|
||||
|
/** READ-ONLY **/ |
||||
|
unsigned short http_major; |
||||
|
unsigned short http_minor; |
||||
|
unsigned short status_code; /* responses only */ |
||||
|
unsigned char method; /* requests only */ |
||||
|
|
||||
|
/* 1 = Upgrade header was present and the parser has exited because of that. |
||||
|
* 0 = No upgrade header present. |
||||
|
* Should be checked when http_parser_execute() returns in addition to |
||||
|
* error checking. |
||||
|
*/ |
||||
|
char upgrade; |
||||
|
|
||||
|
/** PUBLIC **/ |
||||
|
void *data; /* A pointer to get hook to the "connection" or "socket" object */ |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
struct php_http_parser_settings { |
||||
|
php_http_cb on_message_begin; |
||||
|
php_http_data_cb on_path; |
||||
|
php_http_data_cb on_query_string; |
||||
|
php_http_data_cb on_url; |
||||
|
php_http_data_cb on_fragment; |
||||
|
php_http_data_cb on_header_field; |
||||
|
php_http_data_cb on_header_value; |
||||
|
php_http_cb on_headers_complete; |
||||
|
php_http_data_cb on_body; |
||||
|
php_http_cb on_message_complete; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
void php_http_parser_init(php_http_parser *parser, enum php_http_parser_type type); |
||||
|
|
||||
|
|
||||
|
size_t php_http_parser_execute(php_http_parser *parser, |
||||
|
const php_http_parser_settings *settings, |
||||
|
const char *data, |
||||
|
size_t len); |
||||
|
|
||||
|
|
||||
|
/* If php_http_should_keep_alive() in the on_headers_complete or |
||||
|
* on_message_complete callback returns true, then this will be should be |
||||
|
* the last message on the connection. |
||||
|
* If you are the server, respond with the "Connection: close" header. |
||||
|
* If you are the client, close the connection. |
||||
|
*/ |
||||
|
int php_http_should_keep_alive(php_http_parser *parser); |
||||
|
|
||||
|
/* Returns a string version of the HTTP method. */ |
||||
|
const char *php_http_method_str(enum php_http_method); |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
} |
||||
|
#endif |
||||
|
#endif |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue