============
$Id$
-HttpResponse (only in PHP-5.1+):
- HttpResponse::getHeader() does not work in Apache2 with a
-PHP version lower than 5.1.3 (as mod_php).
+PHP < 5.1.3:
+ HttpResponse::getHeader() does not work with Apache2 SAPIs.
+ Using an encoding stream filter on a stream you read from doesn't work.
Windows:
If you keep getting "SSL connect error" when trying to issue
-requests, try another (newer) libeay32.dll/ssleay32.dll pair.
-
-Deflate/Inflate:
- Inflating raw deflated data causes a re-initialization of the inflate
-stream where the corresponding window bits are modified to tell libz to
-not check for zlib header bytes. This is not preventable AFAICS.
- Using an encoding stream filter on a stream you read from, will
-not work as expected in a PHP version lower than 5.1.3.
+ requests, try another (newer) libeay32.dll/ssleay32.dll pair.
Internals:
- - our http_urlencode_hash() does not differentiate between prefixes
+ Our http_urlencode_hash() does not differentiate between prefixes
for numeric or string keys.
- - detaching a request from a pool in its progress callback causes
- all sorts of memory errors
+ Inflating raw deflated data causes a re-initialization of the inflate
+ stream where the corresponding window bits are modified to tell libz
+ to not check for zlib header bytes. This is not preventable AFAICS.
/* char *pretty_key(char *, size_t, zend_bool, zend_bool) */
char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen)
{
+ size_t i;
+ int wasalpha;
+
if (key && key_len) {
- size_t i;
- int wasalpha;
- if ((wasalpha = isalpha((int) key[0]))) {
- key[0] = (char) (uctitle ? toupper((int) key[0]) : tolower((int) key[0]));
+ if ((wasalpha = HTTP_IS_CTYPE(alpha, key[0]))) {
+ key[0] = (char) (uctitle ? HTTP_TO_CTYPE(upper, key[0]) : HTTP_TO_CTYPE(lower, key[0]));
}
for (i = 1; i < key_len; i++) {
- if (isalpha((int) key[i])) {
- key[i] = (char) (((!wasalpha) && uctitle) ? toupper((int) key[i]) : tolower((int) key[i]));
+ if (HTTP_IS_CTYPE(alpha, key[i])) {
+ key[i] = (char) (((!wasalpha) && uctitle) ? HTTP_TO_CTYPE(upper, key[i]) : HTTP_TO_CTYPE(lower, key[i]));
wasalpha = 1;
} else {
if (xhyphen && (key[i] == '_')) {
const char *found;
if ( (found = strstr(methods, method)) &&
- (found == method || !isalpha(found[-1])) &&
- (strlen(found) >= strlen(method) && !isalpha(found[strlen(method)]))) {
+ (found == method || !HTTP_IS_CTYPE(alpha, found[-1])) &&
+ (strlen(found) >= strlen(method) && !HTTP_IS_CTYPE(alpha, found[strlen(method)]))) {
return SUCCESS;
}
return FAILURE;
while (*date && (part < 6)) {
int found = 0;
- while (*date && !isalnum(*date)) {
+ while (*date && !HTTP_IS_CTYPE(alnum, *date)) {
date++;
}
- if (isalpha(*date)) {
+ if (HTTP_IS_CTYPE(alpha, *date)) {
/* a name coming up */
char buf[32] = "";
size_t len;
}
date += len;
}
- else if (isdigit(*date)) {
+ else if (HTTP_IS_CTYPE(digit, *date)) {
/* a digit */
int val;
char *end;
if ((separator = strchr(Z_STRVAL_PP(entry), ';'))) {
const char *ptr = separator;
- while (*++ptr && !isdigit(*ptr) && '.' != *ptr);
+ while (*++ptr && !HTTP_IS_CTYPE(digit, *ptr) && '.' != *ptr);
quality = atof(ptr);
identifier = estrndup(Z_STRVAL_PP(entry), ident_len = separator - Z_STRVAL_PP(entry));
}
freeme = identifier;
- while (isspace(*identifier)) {
+ while (HTTP_IS_CTYPE(space, *identifier)) {
++identifier;
--ident_len;
}
- while (ident_len && isspace(identifier[ident_len - 1])) {
+ while (ident_len && HTTP_IS_CTYPE(space, identifier[ident_len - 1])) {
identifier[--ident_len] = '\0';
}
INIT_ZARR(array, headers);
/* skip leading ws */
- while (isspace(*header)) ++header;
+ while (HTTP_IS_CTYPE(space, *header)) ++header;
line = header;
#define MORE_HEADERS (*(line-1) && !(*(line-1) == '\n' && (*line == '\n' || *line == '\r')))
const char *key = header;
/* skip leading ws */
- while (keylen && isspace(*key)) --keylen && ++key;
+ while (keylen && HTTP_IS_CTYPE(space, *key)) --keylen && ++key;
/* skip trailing ws */
- while (keylen && isspace(key[keylen - 1])) --keylen;
+ while (keylen && HTTP_IS_CTYPE(space, key[keylen - 1])) --keylen;
if (keylen > 0) {
zval **previous = NULL;
value_len += line - colon - 1;
/* skip leading ws */
- while (isspace(*(++colon))) --value_len;
+ while (HTTP_IS_CTYPE(space, *(++colon))) --value_len;
/* skip trailing ws */
- while (isspace(colon[value_len - 1])) --value_len;
+ while (HTTP_IS_CTYPE(space, colon[value_len - 1])) --value_len;
if (value_len > 0) {
value = estrndup(colon, value_len);
*/
if ( (!(http = php_memnstr((char *) pre_header, "HTTP/1.", lenof("HTTP/1."), (char *)end))) ||
(!(http < end)) ||
- (!isdigit(http[lenof("HTTP/1.")])) ||
- (http[lenof("HTTP/1.1")] && (!isspace(http[lenof("HTTP/1.1")])))) {
+ (!HTTP_IS_CTYPE(digit, http[lenof("HTTP/1.")])) ||
+ (http[lenof("HTTP/1.1")] && (!HTTP_IS_CTYPE(space, http[lenof("HTTP/1.1")])))) {
if (!silent) {
http_error(HE_WARNING, HTTP_E_MALFORMED_HEADERS, "Invalid or missing HTTP/1.x protocol identification");
}
/* check for following messages */
if (continue_at && (continue_at < (message + message_length))) {
- while (isspace(*continue_at)) ++continue_at;
+ while (HTTP_IS_CTYPE(space, *continue_at)) ++continue_at;
if (continue_at < (message + message_length)) {
http_message *next = NULL, *most = NULL;
char *http_method, *method, *mconst;
http_request_method_entry **ptr = HTTP_G->request.methods.custom.entries;
- if (!isalpha(*method_name)) {
+ if (!HTTP_IS_CTYPE(alpha, *method_name)) {
http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Request method does not start with a character (%s)", method_name);
return 0;
}
break;
default:
- if (!isalnum(method_name[i])) {
+ if (!HTTP_IS_CTYPE(alnum, method_name[i])) {
efree(method);
efree(mconst);
http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Request method contains illegal characters (%s)", method_name);
return 0;
}
- mconst[i] = method[i] = toupper(method_name[i]);
+ mconst[i] = method[i] = HTTP_TO_CTYPE(upper, method_name[i]);
break;
}
}
/* check for spaces only */
for (i = 0; i < Z_STRLEN_PP(ct_header); ++i) {
- if (!isspace(Z_STRVAL_PP(ct_header)[i])) {
+ if (!HTTP_IS_CTYPE(space, Z_STRVAL_PP(ct_header)[i])) {
only_space = 0;
break;
}
#endif
#include <ctype.h>
+#define HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c))
+#define HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c))
extern zend_module_entry http_module_entry;
#define phpext_http_ptr &http_module_entry