PHP_HTTP_API const char *_http_cookie_list_get_cookie(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC)
{
zval **cookie = NULL;
- if ((SUCCESS != zend_hash_find(&list->cookies, name, name_len + 1, (void **) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) {
+ if ((SUCCESS != zend_hash_find(&list->cookies, (char *) name, name_len + 1, (void **) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) {
return NULL;
}
return Z_STRVAL_PP(cookie);
PHP_HTTP_API const char *_http_cookie_list_get_extra(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC)
{
zval **extra = NULL;
- if ((SUCCESS != zend_hash_find(&list->extras,name, name_len + 1, (void **) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) {
+ if ((SUCCESS != zend_hash_find(&list->extras, (char *) name, name_len + 1, (void **) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) {
return NULL;
}
return Z_STRVAL_PP(extra);
zval *cookie_value;
MAKE_STD_ZVAL(cookie_value);
ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0);
- zend_hash_update(&list->cookies, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
+ zend_hash_update(&list->cookies, (char *) name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
}
PHP_HTTP_API void _http_cookie_list_add_extra(http_cookie_list *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC)
zval *cookie_value;
MAKE_STD_ZVAL(cookie_value);
ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0);
- zend_hash_update(&list->extras, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
+ zend_hash_update(&list->extras, (char *) name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
}
#define http_cookie_list_set_item_ex(l, i, il, v, vl, f, a) _http_cookie_list_set_item_ex((l), (i), (il), (v), (vl), (f), (a) TSRMLS_CC)
case ';':
case '\0':
goto add;
- st = ST_ADD;
break;
default:
php_stream_bucket_append(buckets_out, __buck TSRMLS_CC); \
}
-typedef struct {
+typedef struct _http_chunked_decode_filter_buffer_t {
phpstr buffer;
ulong hexlen;
} HTTP_FILTER_BUFFER(chunked_decode);
}
}
-PHP_HTTP_API void _http_info_dtor(http_info *info)
+PHP_HTTP_API void _http_info_dtor(http_info *i)
{
- http_info_t *i = (http_info_t *) info;
-
- switch (info->type)
+ switch (i->type)
{
case IS_HTTP_REQUEST:
- STR_SET(i->request.method, NULL);
- STR_SET(i->request.url, NULL);
+ STR_SET(HTTP_INFO(i).request.method, NULL);
+ STR_SET(HTTP_INFO(i).request.url, NULL);
break;
case IS_HTTP_RESPONSE:
- STR_SET(i->response.status, NULL);
+ STR_SET(HTTP_INFO(i).response.status, NULL);
break;
default:
*/
PHP_METHOD(HttpResponse, guessContentType)
{
+#ifdef HTTP_HAVE_MAGIC
char *magic_file, *ct = NULL;
int magic_file_len;
- long magic_mode = 0;
+ long magic_mode = MAGIC_MIME;
RETVAL_FALSE;
-
-#ifdef HTTP_HAVE_MAGIC
- magic_mode = MAGIC_MIME;
-
SET_EH_THROW_HTTP();
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &magic_file, &magic_file_len, &magic_mode)) {
switch (Z_LVAL_P(GET_STATIC_PROP(mode))) {
SET_EH_NORMAL();
#else
http_error(HE_THROW, HTTP_E_RUNTIME, "Cannot guess Content-Type; libmagic not available");
+ RETURN_FALSE;
#endif
}
/* }}} */
if (mode && ((!strcasecmp(mode, "crc32")) || (!strcasecmp(mode, "crc32b")))) {
uint i, c = *((uint *) ctx);
for (i = 0; i < data_len; ++i) {
- c = CRC32(c, data_ptr[i]);
+ CRC32(c, data_ptr[i]);
}
*((uint *)ctx) = c;
} else if (mode && (!strcasecmp(mode, "sha1"))) {
cookie params like those from rfc2109 and rfc2965 are just put into extras, if
one specifies them in allowed extras, else they're treated like cookies themself
*/
-typedef struct {
+typedef struct _http_cookie_list_t {
HashTable cookies;
HashTable extras;
long flags;
#define PHP_HTTP_DEFLATESTREAM_OBJECT_H
#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_ZLIB)
-typedef struct {
+typedef struct _http_deflatestream_object_t {
zend_object zo;
http_encoding_stream *stream;
} http_deflatestream_object;
extern PHP_RINIT_FUNCTION(http_encoding);
extern PHP_RSHUTDOWN_FUNCTION(http_encoding);
-typedef enum {
+typedef enum _http_encoding_type_t {
HTTP_ENCODING_NONE,
HTTP_ENCODING_GZIP,
HTTP_ENCODING_DEFLATE,
#define HTTP_ENCODING_STREAM_PERSISTENT 0x01000000
-typedef struct {
+typedef struct _http_encoding_stream_t {
z_stream stream;
int flags;
void *storage;
#include "php_http_info_api.h"
-typedef enum {
+typedef enum http_range_status_t {
RANGE_OK,
RANGE_NO,
RANGE_ERR
#define PHP_HTTP_INFLATESTREAM_OBJECT_H
#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_ZLIB)
-typedef struct {
+typedef struct _http_inflatestream_object_t {
zend_object zo;
http_encoding_stream *stream;
} http_inflatestream_object;
#define HTTP_INFO(ptr) (ptr)->http.info
-typedef struct {
+typedef struct _http_request_info_t {
char *method;
char *url;
} http_request_info;
-typedef struct {
+typedef struct _http_response_info_t {
int code;
char *status;
} http_response_info;
-typedef union {
+typedef union _http_info_union_t {
http_request_info request;
http_response_info response;
-} http_info_t;
+} http_info_union;
struct http_info {
- http_info_t info;
+ http_info_union info;
double version;
};
-typedef struct {
+typedef struct _http_info_t {
struct http_info http;
int type;
} http_info;
#include "php_http_info_api.h"
-typedef enum {
+typedef enum _http_message_type_t {
HTTP_MSG_NONE = 0,
HTTP_MSG_REQUEST = IS_HTTP_REQUEST,
HTTP_MSG_RESPONSE = IS_HTTP_RESPONSE,
} http_message_type;
-typedef struct _http_message http_message;
+typedef struct _http_message_t http_message;
-struct _http_message {
+struct _http_message_t {
phpstr body;
HashTable hdrs;
http_message_type type;
#define PHP_HTTP_MESSAGE_OBJECT_H
#ifdef ZEND_ENGINE_2
-typedef struct {
+typedef struct _http_message_object_t {
zend_object zo;
http_message *message;
zend_object_value parent;
#define PHP_HTTP_QUERYSTRING_OBJECT_H
#ifdef ZEND_ENGINE_2
-typedef struct {
+typedef struct _http_querystring_object_t {
zend_object zo;
} http_querystring_object;
extern PHP_MINIT_FUNCTION(http_request);
extern PHP_MSHUTDOWN_FUNCTION(http_request);
-typedef struct {
+typedef struct _http_request_t {
CURL *ch;
char *url;
http_request_method meth;
#define HTTP_REQUEST_BODY_CSTRING 1
#define HTTP_REQUEST_BODY_CURLPOST 2
#define HTTP_REQUEST_BODY_UPLOADFILE 3
-typedef struct {
+typedef struct _http_request_body_t {
uint type:3;
uint free:1;
uint priv:28;
#ifndef PHP_HTTP_REQUEST_METHOD_API_H
#define PHP_HTTP_REQUEST_METHOD_API_H
-typedef enum {
+typedef enum _http_request_method_t {
+ /* force the enum to be signed */
+ HTTP_NEG_REQUEST_METHOD =-1,
HTTP_NO_REQUEST_METHOD = 0,
/* HTTP/1.1 */
HTTP_GET = 1,
#define HTTP_MIN_REQUEST_METHOD (HTTP_NO_REQUEST_METHOD + 1)
#define HTTP_CUSTOM_REQUEST_METHOD_START HTTP_MAX_REQUEST_METHOD
-typedef struct {
+typedef struct _http_request_method_entry_t {
char *name;
char *cnst;
} http_request_method_entry;
#include "php_http_request_pool_api.h"
-typedef struct {
+typedef struct _http_request_object_t {
zend_object zo;
http_request *request;
http_request_pool *pool;
#define PHP_HTTP_REQUEST_POOL_API_H
#ifdef HTTP_HAVE_CURL
-typedef struct {
+typedef struct _http_request_pool_t {
CURLM *ch;
zend_llist finished;
zend_llist handles;
#ifdef HTTP_HAVE_CURL
#ifdef ZEND_ENGINE_2
-typedef struct {
+typedef struct _http_requestpool_object_t {
zend_object zo;
http_request_pool pool;
struct {
#ifndef PHP_HTTP_SEND_API_H
#define PHP_HTTP_SEND_API_H
-typedef enum {
+typedef enum _http_send_mode_t {
SEND_DATA,
SEND_RSRC
} http_send_mode;
RETVAL_STRINGL((STR)->data, (STR)->used, (dup)); \
FREE_PHPSTR((free), (STR));
-typedef struct {
+typedef struct _phpstr_t {
size_t size;
char *data;
size_t used;
int pmem;
} phpstr;
-typedef enum {
+typedef enum _phpstr_free_t {
PHPSTR_FREE_NOT = 0,
PHPSTR_FREE_PTR, /* pefree() */
PHPSTR_FREE_VAL, /* phpstr_dtor() */
?>
--EXPECTF--
%sTEST
+GET /.print_request.php HTTP/1.1
+User-Agent: %s
+Host: dev.iworks.at
+Accept: */*
+Cookie: name=val%3Due
HTTP/1.1 200 OK
%s
User-Agent: %s
Host: dev.iworks.at
Accept: */*
-Cookie: name=val%3Due
+Cookie: name=val=ue;
HTTP/1.1 200 OK
%s
[name] => val=ue
)
-GET /.print_request.php HTTP/1.1
-User-Agent: %s
-Host: dev.iworks.at
-Accept: */*
-Cookie: name=val=ue;
Done