*decoded = ecalloc(1, encoded_len);
while ((encoded + encoded_len - e_ptr) > 0) {
- unsigned long chunk_len = 0, rest;
+ ulong chunk_len = 0, rest;
chunk_len = strtoul(e_ptr, &n_ptr, 16);
return encoded + encoded_len;
} else {
efree(*decoded);
- http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected chunk size at pos %lu of %lu but got trash", (unsigned long) (n_ptr - encoded), (unsigned long) encoded_len);
+ http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected chunk size at pos %lu of %lu but got trash", (ulong) (n_ptr - encoded), (ulong) encoded_len);
return NULL;
}
}
/* there should be CRLF after the chunk size, but we'll ignore SP+ too */
if (*n_ptr && !eol_match(&n_ptr, &eol_len)) {
if (eol_len == 2) {
- http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected CRLF at pos %lu of %lu but got 0x%02X 0x%02X", (unsigned long) (n_ptr - encoded), (unsigned long) encoded_len, *n_ptr, *(n_ptr + 1));
+ http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected CRLF at pos %lu of %lu but got 0x%02X 0x%02X", (ulong) (n_ptr - encoded), (ulong) encoded_len, *n_ptr, *(n_ptr + 1));
} else {
- http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected LF at pos %lu of %lu but got 0x%02X", (unsigned long) (n_ptr - encoded), (unsigned long) encoded_len, *n_ptr);
+ http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Expected LF at pos %lu of %lu but got 0x%02X", (ulong) (n_ptr - encoded), (ulong) encoded_len, *n_ptr);
}
}
n_ptr += eol_len;
/* chunk size pretends more data than we actually got, so it's probably a truncated message */
if (chunk_len > (rest = encoded + encoded_len - n_ptr)) {
- http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %lu of %lu", chunk_len, rest, (unsigned long) (n_ptr - encoded), (unsigned long) encoded_len);
+ http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %lu of %lu", chunk_len, rest, (ulong) (n_ptr - encoded), (ulong) encoded_len);
chunk_len = rest;
}
inline size_t http_finish_gzencode_buffer(z_stream *Z, const char *data, size_t data_len, char **buf_ptr)
{
- unsigned long crc;
+ ulong crc;
char *trailer;
crc = crc32(0L, Z_NULL, 0);
if (data_len <= offset) {
goto really_bad_gzip_header;
} else {
- unsigned long crc, cmp;
+ ulong crc, cmp;
cmp = (unsigned) ((data[offset-2] & 0xFF));
cmp += (unsigned) ((data[offset-1] & 0xFF) << 8);
inline STATUS http_verify_gzdecode_buffer(const char *data, size_t data_len, const char *decoded, size_t decoded_len, int error_level TSRMLS_DC)
{
STATUS status = SUCCESS;
- unsigned long len, cmp, crc;
+ ulong len, cmp, crc;
crc = crc32(0L, Z_NULL, 0);
crc = crc32(crc, (const Bytef *) decoded, decoded_len);
if (content_length) {
char cl_header_str[128];
size_t cl_header_len;
- cl_header_len = snprintf(cl_header_str, lenof(cl_header_str), "Content-Length: %lu", (unsigned long) content_length);
+ cl_header_len = snprintf(cl_header_str, lenof(cl_header_str), "Content-Length: %lu", (ulong) content_length);
http_send_header_string_ex(cl_header_str, cl_header_len, 1);
}
} else {
{
char *method;
int method_len;
- unsigned long existing;
+ ulong existing;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &method, &method_len)) {
RETURN_FALSE;
if (is_numeric_string(Z_STRVAL_P(method), Z_STRLEN_P(method), NULL, NULL, 1)) {
convert_to_long(method);
} else {
- unsigned long mn;
+ ulong mn;
if (!(mn = http_request_method_exists(1, 0, Z_STRVAL_P(method)))) {
RETURN_FALSE;
}
RETURN_FALSE;
}
- RETURN_STRING(estrdup(http_request_method_name((unsigned long) method)), 0);
+ RETURN_STRING(estrdup(http_request_method_name((ulong) method)), 0);
}
}
/* }}} */
/* message has content-length header */
if (c = http_message_header(msg, "Content-Length")) {
- unsigned long len = strtoul(Z_STRVAL_P(c), NULL, 10);
+ ulong len = strtoul(Z_STRVAL_P(c), NULL, 10);
if (len > remaining) {
http_error_ex(HE_NOTICE, HTTP_E_MALFORMED_HEADERS, "The Content-Length header pretends a larger body than actually received (expected %lu bytes; got %lu bytes)", len, remaining);
len = remaining;
}
if (end >= start && (!total || end < total)) {
phpstr_from_string_ex(PHPSTR(msg), body, len);
- continue_at = body + (end + 1 - start);
+ continue_at = body + len;
}
}
}
#endif
if (type == BP_VAR_W) {
- return_value = &EG(uninitialized_zval);
- return_value->refcount = 1;
- return_value->is_ref = 1;
- } else {
- ALLOC_ZVAL(return_value);
- return_value->refcount = 0;
- return_value->is_ref = 0;
+ zend_error(E_ERROR, "Cannot access HttpMessage properties by reference or array key/index");
+ return NULL;
}
+
+ ALLOC_ZVAL(return_value);
+ return_value->refcount = 0;
+ return_value->is_ref = 0;
#ifdef WONKY
switch (h)
case HTTP_MSG_PROPHASH_BODY:
case HTTP_MSG_CHILD_PROPHASH_BODY:
phpstr_fix(PHPSTR(msg));
- RETVAL_PHPSTR(PHPSTR(msg), 0, !return_value->is_ref);
+ RETVAL_PHPSTR(PHPSTR(msg), 0, 1);
break;
case HTTP_MSG_PROPHASH_HEADERS:
case HTTP_MSG_CHILD_PROPHASH_HEADERS:
- if (return_value->is_ref) {
- Z_TYPE_P(return_value) = IS_ARRAY;
- Z_ARRVAL_P(return_value) = &msg->hdrs;
- } else {
- array_init(return_value);
- zend_hash_copy(Z_ARRVAL_P(return_value), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
- }
+ array_init(return_value);
+ zend_hash_copy(Z_ARRVAL_P(return_value), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
break;
case HTTP_MSG_PROPHASH_PARENT_MESSAGE:
case HTTP_MSG_PROPHASH_REQUEST_METHOD:
case HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD:
if (HTTP_MSG_TYPE(REQUEST, msg) && msg->http.info.request.method) {
- RETVAL_STRING(msg->http.info.request.method, !return_value->is_ref);
+ RETVAL_STRING(msg->http.info.request.method, 1);
} else {
RETVAL_NULL();
}
case HTTP_MSG_PROPHASH_REQUEST_URI:
case HTTP_MSG_CHILD_PROPHASH_REQUEST_URI:
if (HTTP_MSG_TYPE(REQUEST, msg) && msg->http.info.request.URI) {
- RETVAL_STRING(msg->http.info.request.URI, !return_value->is_ref);
+ RETVAL_STRING(msg->http.info.request.URI, 1);
} else {
RETVAL_NULL();
}
case HTTP_MSG_PROPHASH_RESPONSE_STATUS:
case HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS:
if (HTTP_MSG_TYPE(RESPONSE, msg) && msg->http.info.response.status) {
- RETVAL_STRING(msg->http.info.response.status, !return_value->is_ref);
+ RETVAL_STRING(msg->http.info.response.status, 1);
} else {
RETVAL_NULL();
}
{
HTTP_REQUEST_CALLBACK_DATA(ctx, http_request_conv *, conv);
-#if 0
- fprintf(stderr, "DEBUG: %s\n", data);
-#endif
-
switch (type)
{
case CURLINFO_DATA_IN:
phpstr_append(conv->request, data, length);
}
break;
+#if 0
+ default:
+ fprintf(stderr, "## ", type);
+ if (!type) {
+ fprintf(stderr, "%s", data);
+ } else {
+ ulong i;
+ for (i = 1; i <= length; ++i) {
+ fprintf(stderr, "%02X ", data[i-1] & 0xFF);
+ if (!(i % 20)) {
+ fprintf(stderr, "\n## ");
+ }
+ }
+ fprintf(stderr, "\n");
+ }
+ if (data[length-1] != 0xa) {
+ fprintf(stderr, "\n");
+ }
+ break;
+#endif
}
if (type) {
}
}
-static unsigned long http_ssl_id(void)
+static ulong http_ssl_id(void)
{
- return (unsigned long) tsrm_thread_id();
+ return (ulong) tsrm_thread_id();
}
static inline void http_ssl_init(void)
}
/* }}} */
-/* {{{ unsigned long http_request_method_exists(zend_bool, unsigned long, char *) */
-PHP_HTTP_API unsigned long _http_request_method_exists(zend_bool by_name, unsigned long id, const char *name TSRMLS_DC)
+/* {{{ ulong http_request_method_exists(zend_bool, ulong, char *) */
+PHP_HTTP_API ulong _http_request_method_exists(zend_bool by_name, ulong id, const char *name TSRMLS_DC)
{
if (by_name) {
unsigned i;
}
/* }}} */
-/* {{{ unsigned long http_request_method_register(char *) */
-PHP_HTTP_API unsigned long _http_request_method_register(const char *method_name, size_t method_name_len TSRMLS_DC)
+/* {{{ ulong http_request_method_register(char *) */
+PHP_HTTP_API ulong _http_request_method_register(const char *method_name, size_t method_name_len TSRMLS_DC)
{
zval array;
char *http_method, *method;
- unsigned long i, meth_num = HTTP_G(request).methods.custom.nNextFreeElement + HTTP_MAX_REQUEST_METHOD;
+ ulong i, meth_num = HTTP_G(request).methods.custom.nNextFreeElement + HTTP_MAX_REQUEST_METHOD;
method = emalloc(method_name_len + 1);
for (i = 0; i < method_name_len; ++i) {
/* }}} */
/* {{{ STATUS http_request_method_unregister(usngigned long) */
-PHP_HTTP_API STATUS _http_request_method_unregister(unsigned long method TSRMLS_DC)
+PHP_HTTP_API STATUS _http_request_method_unregister(ulong method TSRMLS_DC)
{
zval **zmethod;
char *http_method;
char range_header_str[256];
size_t range_header_len;
- range_header_len = snprintf(range_header_str, lenof(range_header_str), "Content-Range: bytes %ld-%ld/%lu", Z_LVAL_PP(begin), Z_LVAL_PP(end), (unsigned long) data_size);
+ range_header_len = snprintf(range_header_str, lenof(range_header_str), "Content-Range: bytes %ld-%ld/%lu", Z_LVAL_PP(begin), Z_LVAL_PP(end), (ulong) data_size);
http_send_status_header_ex(206, range_header_str, range_header_len, 1);
http_send_response_start(&s, Z_LVAL_PP(end)-Z_LVAL_PP(begin)+1);
http_send_response_data_fetch(&s, data_ptr, data_size, data_mode, Z_LVAL_PP(begin), Z_LVAL_PP(end) + 1);
char boundary_str[32], range_header_str[256];
size_t boundary_len, range_header_len;
- boundary_len = snprintf(boundary_str, lenof(boundary_str), "%lu%0.9f", (unsigned long) time(NULL), (float) php_combined_lcg(TSRMLS_C));
+ boundary_len = snprintf(boundary_str, lenof(boundary_str), "%lu%0.9f", (ulong) time(NULL), (float) php_combined_lcg(TSRMLS_C));
range_header_len = snprintf(range_header_str, lenof(range_header_str), "Content-Type: multipart/byteranges; boundary=%s", boundary_str);
http_send_status_header_ex(206, range_header_str, range_header_len, 1);
switch (mode)
{
case HTTP_ETAG_CRC32:
- ctx = emalloc(sizeof(unsigned int));
- *((unsigned int *) ctx) = ~0;
+ ctx = emalloc(sizeof(uint));
+ *((uint *) ctx) = ~0;
break;
case HTTP_ETAG_SHA1:
switch (mode)
{
case HTTP_ETAG_CRC32:
- if (*((unsigned int **) ctx_ptr)) {
- efree(*((unsigned int **) ctx_ptr));
- *((unsigned int **) ctx_ptr) = NULL;
+ if (*((uint **) ctx_ptr)) {
+ efree(*((uint **) ctx_ptr));
+ *((uint **) ctx_ptr) = NULL;
}
break;
switch (mode)
{
case HTTP_ETAG_CRC32:
- **((unsigned int **) ctx_ptr) = ~**((unsigned int **) ctx_ptr);
- etag = http_etag_digest(*((const unsigned char **) ctx_ptr), sizeof(unsigned int));
+ **((uint **) ctx_ptr) = ~**((uint **) ctx_ptr);
+ etag = http_etag_digest(*((const unsigned char **) ctx_ptr), sizeof(uint));
break;
case HTTP_ETAG_SHA1:
{
case HTTP_ETAG_CRC32:
{
- unsigned int i, c = *((unsigned int *) ctx);
+ uint i, c = *((uint *) ctx);
for (i = 0; i < data_len; ++i) {
c = CRC32(c, data_ptr[i]);
}
- *((unsigned int *)ctx) = c;
+ *((uint *)ctx) = c;
}
break;
typedef struct {
z_stream Z;
int gzip;
- unsigned long crc;
+ ulong crc;
phpstr *storage;
} http_encoding_stream;
PHP_HTTP_API const char *_http_request_method_name(http_request_method m TSRMLS_DC);
#define http_request_method_exists(u, l, c) _http_request_method_exists((u), (l), (c) TSRMLS_CC)
-PHP_HTTP_API unsigned long _http_request_method_exists(zend_bool by_name, unsigned long id, const char *name TSRMLS_DC);
+PHP_HTTP_API ulong _http_request_method_exists(zend_bool by_name, ulong id, const char *name TSRMLS_DC);
#define http_request_method_register(m, l) _http_request_method_register((m), (l) TSRMLS_CC)
-PHP_HTTP_API unsigned long _http_request_method_register(const char *method, size_t method_name_len TSRMLS_DC);
+PHP_HTTP_API ulong _http_request_method_register(const char *method, size_t method_name_len TSRMLS_DC);
#define http_request_method_unregister(mn) _http_request_method_unregister((mn) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_request_method_unregister(unsigned long method TSRMLS_DC);
+PHP_HTTP_API STATUS _http_request_method_unregister(ulong method TSRMLS_DC);
#endif