/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(http)
{
- char *m;
-
- if (m = INI_STR("http.allowed_methods")) {
- http_check_allowed_methods(m, strlen(m));
+ if (HTTP_G(request).methods.allowed) {
+ http_check_allowed_methods(HTTP_G(request).methods.allowed,
+ strlen(HTTP_G(request).methods.allowed));
}
http_globals_init(HTTP_GLOBALS);
if (key && key_len) {
size_t i;
int wasalpha;
- if (wasalpha = isalpha((int) key[0])) {
+ if ((wasalpha = isalpha((int) key[0]))) {
key[0] = (char) (uctitle ? toupper((int) key[0]) : tolower((int) key[0]));
}
for (i = 1; i < key_len; i++) {
HTTP_GSC(zmodified, entry, !enforce_presence);
modified = estrndup(Z_STRVAL_P(zmodified), Z_STRLEN_P(zmodified));
- if (chr_ptr = strrchr(modified, ';')) {
+ if ((chr_ptr = strrchr(modified, ';'))) {
chr_ptr = 0;
}
retval = (t <= http_parse_date(modified));
{
struct tm *gmtime, tmbuf;
- if (gmtime = php_gmtime_r(&t, &tmbuf)) {
+ if ((gmtime = php_gmtime_r(&t, &tmbuf))) {
char *date = ecalloc(1, 31);
snprintf(date, 30,
"%s, %02d %s %04d %02d:%02d:%02d GMT",
HTTP_ENCODING_STREAM_ERROR(status, NULL);
}
- if (s->gzip = gzip) {
+ if ((s->gzip = gzip)) {
s->crc = crc32(0L, Z_NULL, 0);
*encoded_len = sizeof(http_encoding_gzip_header);
*encoded = emalloc(*encoded_len);
HTTP_G(send).gzip_encoding = 0;
- if (selected = http_negotiate_encoding(&zsupported)) {
+ if ((selected = http_negotiate_encoding(&zsupported))) {
STATUS hs = FAILURE;
char *encoding = NULL;
ulong idx;
/* we need eol, so we can be sure we have all hex digits */
phpstr_fix(PHPSTR(buffer));
- if (eolstr = http_locate_eol(PHPSTR_VAL(buffer), &eollen)) {
+ if ((eolstr = http_locate_eol(PHPSTR_VAL(buffer), &eollen))) {
char *stop = NULL;
/* read in chunk size */
if (!strcasecmp(name, "http.chunked_decode")) {
http_filter_buffer *b = NULL;
- if (b = pecalloc(1, sizeof(http_filter_buffer), p)) {
+ if ((b = pecalloc(1, sizeof(http_filter_buffer), p))) {
phpstr_init_ex(PHPSTR(b), 4096, p ? PHPSTR_INIT_PERSISTENT : 0);
if (!(f = php_stream_filter_alloc(&HTTP_FILTER_OP(chunked_decode), b, p))) {
pefree(b, p);
#define HTTP_DO_NEGOTIATE(type, supported, rs_array) \
{ \
HashTable *result; \
- if (result = http_negotiate_ ##type(supported)) { \
+ if ((result = http_negotiate_ ##type(supported))) { \
char *key; \
uint key_len; \
ulong idx; \
/* 0 or omitted */
if (!last_modified) {
/* does the client have? (att: caching "forever") */
- if (zlm = http_get_server_var("HTTP_IF_MODIFIED_SINCE")) {
+ if ((zlm = http_get_server_var("HTTP_IF_MODIFIED_SINCE"))) {
last_modified = send_modified = http_parse_date(Z_STRVAL_P(zlm));
/* send current time */
} else {
RETURN_NULL();
}
- if (msg = http_message_parse(message, message_len)) {
+ if ((msg = http_message_parse(message, message_len))) {
object_init(return_value);
http_message_tostruct_recursive(msg, return_value);
http_message_free(&msg);
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &method, &method_len)) {
RETURN_FALSE;
}
- if (existing = http_request_method_exists(1, 0, method)) {
+ if ((existing = http_request_method_exists(1, 0, method))) {
RETURN_LONG((long) existing);
}
}
/* no distinct match found, so try primaries */
- if (dash_test = strchr(test, '-')) {
+ if ((dash_test = strchr(test, '-'))) {
FOREACH_HASH_VAL(pos, supported, value) {
int len = dash_test - test;
#if HTTP_DBG_NEG
fprintf(stderr, "Checking %s\n", Z_STRVAL_PP(entry));
#endif
- if (separator = strchr(Z_STRVAL_PP(entry), ';')) {
+ if ((separator = strchr(Z_STRVAL_PP(entry), ';'))) {
const char *ptr = separator;
while (*++ptr && !isdigit(*ptr));
identifier = estrndup(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry));
}
- if (selected = neg(identifier, &quality, supported TSRMLS_CC)) {
+ if ((selected = neg(identifier, &quality, supported TSRMLS_CC))) {
/* don't overwrite previously set with higher quality */
if (!zend_hash_exists(Z_ARRVAL(array), selected, strlen(selected) + 1)) {
add_assoc_double(&array, selected, quality);
}
/* header parsing stops at (CR)LF (CR)LF */
- if (body = http_locate_body(message)) {
+ if ((body = http_locate_body(message))) {
zval *c;
const char *continue_at = NULL;
size_t remaining = message + message_length - body;
size_t decoded_len;
/* decode and replace Transfer-Encoding with Content-Length header */
- if (continue_at = http_encoding_dechunk(body, message + message_length - body, &decoded, &decoded_len)) {
+ if ((continue_at = http_encoding_dechunk(body, message + message_length - body, &decoded, &decoded_len))) {
zval *len;
char *tmp;
int tmp_len;
} else
/* message has content-length header */
- if (c = http_message_header(msg, "Content-Length")) {
+ if ((c = http_message_header(msg, "Content-Length"))) {
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);
} else
/* message has content-range header */
- if (c = http_message_header(msg, "Content-Range")) {
+ if ((c = http_message_header(msg, "Content-Range"))) {
ulong total = 0, start = 0, end = 0, len = 0;
if (!strncasecmp(Z_STRVAL_P(c), "bytes", lenof("bytes")) &&
#if defined(HTTP_HAVE_ZLIB) || defined(HAVE_ZLIB)
/* check for compressed data */
- if (c = http_message_header(msg, "Content-Encoding")) {
+ if ((c = http_message_header(msg, "Content-Encoding"))) {
char *decoded = NULL;
size_t decoded_len = 0;
# if defined(HAVE_ZLIB) && !defined(HTTP_HAVE_ZLIB)
http_message *next = NULL, *most = NULL;
/* set current message to parent of most parent following messages and return deepest */
- if (most = next = http_message_parse(continue_at, message + message_length - continue_at)) {
+ if ((most = next = http_message_parse(continue_at, message + message_length - continue_at))) {
while (most->parent) most = most->parent;
most->parent = msg;
msg = next;
http_message_tostring(message, &buf, &len);
phpstr_prepend(&str, buf, len);
efree(buf);
- } while (message = message->parent);
+ } while ((message = message->parent));
buf = phpstr_data(&str, string, length);
if (!string) {
add_assoc_string(&strct, "requestMethod", msg->http.info.request.method, 1);
add_assoc_string(&strct, "requestUri", msg->http.info.request.URI, 1);
break;
+
+ case HTTP_MSG_NONE:
+ /* avoid compiler warning */
+ break;
}
MAKE_STD_ZVAL(headers);
int port = 0;
/* check for port */
- if (colon = strchr(Z_STRVAL_PP(zhost), ':')) {
+ if ((colon = strchr(Z_STRVAL_PP(zhost), ':'))) {
port = atoi(colon + 1);
host = estrndup(Z_STRVAL_PP(zhost), host_len = (Z_STRVAL_PP(zhost) - colon - 1));
} else {
http_message *msg = obj->message;
http_message_dtor(msg);
- if (obj->message = http_message_parse_ex(msg, message, length)) {
+ if ((obj->message = http_message_parse_ex(msg, message, length))) {
if (obj->message->parent) {
obj->parent = http_message_object_new_ex(Z_OBJCE_P(getThis()), obj->message->parent, NULL);
}
SET_EH_THROW_HTTP();
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &length)) {
- if (msg = http_message_parse(string, length)) {
+ if ((msg = http_message_parse(string, length))) {
ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL));
}
}
#endif
/* progress callback */
- if (zoption = http_curl_getopt(options, "onprogress", 0)) {
+ if ((zoption = http_curl_getopt(options, "onprogress", 0))) {
HTTP_CURL_OPT(NOPROGRESS, 0);
HTTP_CURL_OPT(PROGRESSFUNCTION, http_curl_progress_callback);
HTTP_CURL_OPT(PROGRESSDATA, http_request_callback_data(zoption));
}
/* proxy */
- if (zoption = http_curl_getopt(options, "proxyhost", IS_STRING)) {
+ if ((zoption = http_curl_getopt(options, "proxyhost", IS_STRING))) {
HTTP_CURL_OPT(PROXY, http_request_data_copy(COPY_STRING, Z_STRVAL_P(zoption)));
/* port */
- if (zoption = http_curl_getopt(options, "proxyport", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "proxyport", IS_LONG))) {
HTTP_CURL_OPT(PROXYPORT, Z_LVAL_P(zoption));
}
/* user:pass */
- if (zoption = http_curl_getopt(options, "proxyauth", IS_STRING)) {
+ if ((zoption = http_curl_getopt(options, "proxyauth", IS_STRING))) {
HTTP_CURL_OPT(PROXYUSERPWD, http_request_data_copy(COPY_STRING, Z_STRVAL_P(zoption)));
}
#if LIBCURL_VERSION_NUM >= 0x070a07
/* auth method */
- if (zoption = http_curl_getopt(options, "proxyauthtype", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "proxyauthtype", IS_LONG))) {
HTTP_CURL_OPT(PROXYAUTH, Z_LVAL_P(zoption));
}
#endif
}
/* outgoing interface */
- if (zoption = http_curl_getopt(options, "interface", IS_STRING)) {
+ if ((zoption = http_curl_getopt(options, "interface", IS_STRING))) {
HTTP_CURL_OPT(INTERFACE, http_request_data_copy(COPY_STRING, Z_STRVAL_P(zoption)));
}
/* another port */
- if (zoption = http_curl_getopt(options, "port", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "port", IS_LONG))) {
HTTP_CURL_OPT(PORT, Z_LVAL_P(zoption));
}
/* auth */
- if (zoption = http_curl_getopt(options, "httpauth", IS_STRING)) {
+ if ((zoption = http_curl_getopt(options, "httpauth", IS_STRING))) {
HTTP_CURL_OPT(USERPWD, http_request_data_copy(COPY_STRING, Z_STRVAL_P(zoption)));
}
#if LIBCURL_VERSION_NUM >= 0x070a06
- if (zoption = http_curl_getopt(options, "httpauthtype", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "httpauthtype", IS_LONG))) {
HTTP_CURL_OPT(HTTPAUTH, Z_LVAL_P(zoption));
}
#endif
}
/* redirects, defaults to 0 */
- if (zoption = http_curl_getopt(options, "redirect", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "redirect", IS_LONG))) {
HTTP_CURL_OPT(FOLLOWLOCATION, Z_LVAL_P(zoption) ? 1 : 0);
HTTP_CURL_OPT(MAXREDIRS, Z_LVAL_P(zoption));
- if (zoption = http_curl_getopt(options, "unrestrictedauth", IS_BOOL)) {
+ if ((zoption = http_curl_getopt(options, "unrestrictedauth", IS_BOOL))) {
HTTP_CURL_OPT(UNRESTRICTED_AUTH, Z_LVAL_P(zoption));
}
}
/* referer */
- if (zoption = http_curl_getopt(options, "referer", IS_STRING)) {
+ if ((zoption = http_curl_getopt(options, "referer", IS_STRING))) {
HTTP_CURL_OPT(REFERER, http_request_data_copy(COPY_STRING, Z_STRVAL_P(zoption)));
}
/* useragent, default "PECL::HTTP/version (PHP/version)" */
- if (zoption = http_curl_getopt(options, "useragent", IS_STRING)) {
+ if ((zoption = http_curl_getopt(options, "useragent", IS_STRING))) {
HTTP_CURL_OPT(USERAGENT, http_request_data_copy(COPY_STRING, Z_STRVAL_P(zoption)));
}
/* additional headers, array('name' => 'value') */
- if (zoption = http_curl_getopt(options, "headers", IS_ARRAY)) {
+ if ((zoption = http_curl_getopt(options, "headers", IS_ARRAY))) {
char *header_key;
ulong header_idx;
HashPosition pos;
}
/* cookies, array('name' => 'value') */
- if (zoption = http_curl_getopt(options, "cookies", IS_ARRAY)) {
+ if ((zoption = http_curl_getopt(options, "cookies", IS_ARRAY))) {
char *cookie_key = NULL;
ulong cookie_idx = 0;
HashPosition pos;
}
/* session cookies */
- if (zoption = http_curl_getopt(options, "cookiesession", IS_BOOL)) {
+ if ((zoption = http_curl_getopt(options, "cookiesession", IS_BOOL))) {
if (Z_LVAL_P(zoption)) {
/* accept cookies for this session */
HTTP_CURL_OPT(COOKIEFILE, "");
}
/* maxfilesize */
- if (zoption = http_curl_getopt(options, "maxfilesize", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "maxfilesize", IS_LONG))) {
HTTP_CURL_OPT(MAXFILESIZE, Z_LVAL_P(zoption));
}
/* lastmodified */
- if (zoption = http_curl_getopt(options, "lastmodified", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "lastmodified", IS_LONG))) {
if (Z_LVAL_P(zoption)) {
if (Z_LVAL_P(zoption) > 0) {
HTTP_CURL_OPT(TIMEVALUE, Z_LVAL_P(zoption));
}
/* timeout, defaults to 0 */
- if (zoption = http_curl_getopt(options, "timeout", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "timeout", IS_LONG))) {
HTTP_CURL_OPT(TIMEOUT, Z_LVAL_P(zoption));
}
/* connecttimeout, defaults to 3 */
- if (zoption = http_curl_getopt(options, "connecttimeout", IS_LONG)) {
+ if ((zoption = http_curl_getopt(options, "connecttimeout", IS_LONG))) {
HTTP_CURL_OPT(CONNECTTIMEOUT, Z_LVAL_P(zoption));
}
/* ssl */
- if (zoption = http_curl_getopt(options, "ssl", IS_ARRAY)) {
+ if ((zoption = http_curl_getopt(options, "ssl", IS_ARRAY))) {
ulong idx;
char *key = NULL;
zval **param;
HTTP_CURL_OPT_SSL_LONG_(VERIFYHOST);
HTTP_CURL_OPT_SSL_STRING_(CIPHER_LIST);
-
HTTP_CURL_OPT_STRING(CAINFO);
#if LIBCURL_VERSION_NUM >= 0x070908
HTTP_CURL_OPT_STRING(CAPATH);
phpstr_append(conv->request, data, length);
}
break;
-#if 0
default:
+#if 0
fprintf(stderr, "## ", type);
if (!type) {
fprintf(stderr, "%s", data);
if (data[length-1] != 0xa) {
fprintf(stderr, "\n");
}
- break;
#endif
+ break;
}
if (type) {
getObject(http_request_object, obj);
SET_EH_THROW_HTTP();
- if (msg = http_message_parse(PHPSTR_VAL(&obj->request), PHPSTR_LEN(&obj->request))) {
+ if ((msg = http_message_parse(PHPSTR_VAL(&obj->request), PHPSTR_LEN(&obj->request)))) {
ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL));
}
SET_EH_NORMAL();
getObject(http_request_object, obj);
SET_EH_THROW_HTTP();
- if (msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history))) {
+ if ((msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history)))) {
ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL));
}
SET_EH_NORMAL();
while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(pool->ch, &pool->unfinished));
- while (msg = curl_multi_info_read(pool->ch, &remaining)) {
+ while ((msg = curl_multi_info_read(pool->ch, &remaining))) {
if (CURLMSG_DONE == msg->msg) {
if (CURLE_OK != msg->data.result) {
http_error(HE_WARNING, HTTP_E_REQUEST, curl_easy_strerror(msg->data.result));
}
UPD_STATIC_PROP(long, lastModified, http_last_modified(the_data, SEND_DATA));
- if (etag = http_etag(Z_STRVAL_P(the_data), Z_STRLEN_P(the_data), SEND_DATA)) {
+ if ((etag = http_etag(Z_STRVAL_P(the_data), Z_STRLEN_P(the_data), SEND_DATA))) {
UPD_STATIC_PROP(string, eTag, etag);
efree(etag);
}
zend_list_addref(Z_LVAL_P(the_stream));
UPD_STATIC_PROP(long, lastModified, http_last_modified(the_real_stream, SEND_RSRC));
- if (etag = http_etag(the_real_stream, 0, SEND_RSRC)) {
+ if ((etag = http_etag(the_real_stream, 0, SEND_RSRC))) {
UPD_STATIC_PROP(string, eTag, etag);
efree(etag);
}
}
UPD_STATIC_PROP(long, lastModified, http_last_modified(the_file, -1));
- if (etag = http_etag(the_file, 0, -1)) {
+ if ((etag = http_etag(the_file, 0, -1))) {
UPD_STATIC_PROP(string, eTag, etag);
efree(etag);
}
zend_hash_init(&ranges, 0, NULL, ZVAL_PTR_DTOR, 0);
range_status = http_get_request_ranges(&ranges, data_size);
- if (range_status == RANGE_ERR) {
- zend_hash_destroy(&ranges);
- http_send_status(416);
- return FAILURE;
- }
-
switch (range_status)
{
+ case RANGE_ERR:
+ {
+ zend_hash_destroy(&ranges);
+ http_send_status(416);
+ return FAILURE;
+ }
case RANGE_OK:
{
/* Range Request - only send ranges if entity hasn't changed */
if (!no_cache && cache_etag) {
char *etag = NULL;
- if (etag = http_etag(data_ptr, data_size, data_mode)) {
+ if ((etag = http_etag(data_ptr, data_size, data_mode))) {
char *sent_header = NULL;
http_send_etag_ex(etag, strlen(etag), &sent_header);
furl.port = purl->port;
} else if (strncmp(furl.scheme, "http", 4)) {
#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
- if (se = getservbyname(furl.scheme, "tcp")) {
+ if ((se = getservbyname(furl.scheme, "tcp"))) {
furl.port = se->s_port;
}
#endif
PHPSTR_API phpstr *phpstr_from_string_ex(phpstr *buf, const char *string, size_t length)
{
- if (buf = phpstr_init(buf)) {
+ if ((buf = phpstr_init(buf))) {
if (NOMEM == phpstr_append(buf, string, length)) {
pefree(buf, buf->pmem);
buf = NULL;
char *chunk = NULL;
size_t got = 0;
- while (got = phpstr_chunk_buffer(s, data, data_len, &chunk, chunk_len)) {
+ while ((got = phpstr_chunk_buffer(s, data, data_len, &chunk, chunk_len))) {
passthru(chunk, got TSRMLS_CC);
if (!chunk_len) {
/* we already got the last chunk,