PHPWRITE(body, strlen(body));
}
- switch (status)
- {
+ switch (status) {
case 301: http_log(HTTP_G->log.redirect, "301-REDIRECT", header); break;
case 302: http_log(HTTP_G->log.redirect, "302-REDIRECT", header); break;
case 303: http_log(HTTP_G->log.redirect, "303-REDIRECT", header); break;
);
STR_FREE(tk); STR_FREE(tv);
#endif
- switch (st)
- {
+ switch (st) {
case ST_QUOTE:
quote:
if (*c == '"') {
st = ST_ADD;
}
}
- break;
+ break;
case ST_VALUE:
- switch (*c)
- {
+ switch (*c) {
case '"':
if (!val) {
st = ST_QUOTE;
}
- break;
+ break;
case ' ':
- break;
+ break;
case ';':
case '\0':
goto add;
- break;
+ break;
default:
if (!val) {
val = c;
}
- break;
+ break;
}
- break;
+ break;
case ST_KEY:
- switch (*c)
- {
+ switch (*c) {
case ',':
if (allow_comma_sep) {
goto allow_comma;
case '\013':
case '\014':
goto failure;
- break;
+ break;
case '=':
if (key) {
} else {
goto failure;
}
- break;
+ break;
case ' ':
if (key) {
keylen = c - key;
st = ST_ASSIGN;
}
- break;
+ break;
case ';':
case '\0':
keylen = c - key;
st = ST_ADD;
}
- break;
+ break;
default:
if (!key) {
key = c;
}
- break;
+ break;
}
- break;
+ break;
case ST_ASSIGN:
if (*c == '=') {
} else if (*c != ' ') {
goto failure;
}
- break;
+ break;
case ST_ADD:
add:
st = ST_KEY;
key = val = NULL;
keylen = vallen = 0;
- break;
+ break;
}
if (*c) {
{
php_stream_statbuf ssb;
- switch (data_mode)
- {
+ switch (data_mode) {
case SEND_DATA: return HTTP_GET_REQUEST_TIME();
case SEND_RSRC: return php_stream_stat((php_stream *) data_ptr, &ssb) ? 0 : ssb.sb.st_mtime;
default: return php_stream_stat_path((char *) data_ptr, &ssb) ? 0 : ssb.sb.st_mtime;
Z.next_in = (Bytef *) data;
Z.avail_in = data_len;
- switch (status = http_inflate_rounds(&Z, Z_NO_FLUSH, decoded, decoded_len))
- {
+ switch (status = http_inflate_rounds(&Z, Z_NO_FLUSH, decoded, decoded_len)) {
case Z_OK:
case Z_STREAM_END:
return SUCCESS;
- break;
case Z_DATA_ERROR:
/* raw deflated data? */
wbits = HTTP_WINDOW_BITS_RAW;
goto retry_raw_inflate;
}
- break;
}
inflateEnd(&Z);
}
s->stream.avail_out = *encoded_len;
s->stream.next_out = (Bytef *) *encoded;
- switch (status = deflate(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags)))
- {
+ switch (status = deflate(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags))) {
case Z_OK:
case Z_STREAM_END:
/* cut processed chunk off the buffer */
*encoded = erealloc_rel(*encoded, *encoded_len + 1);
(*encoded)[*encoded_len] = '\0';
return SUCCESS;
- break;
}
STR_SET(*encoded, NULL);
s->stream.next_in = (Bytef *) PHPSTR_VAL(s->stream.opaque);
s->stream.avail_in = PHPSTR_LEN(s->stream.opaque);
- switch (status = http_inflate_rounds(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags), decoded, decoded_len))
- {
+ switch (status = http_inflate_rounds(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags), decoded, decoded_len)) {
case Z_OK:
case Z_STREAM_END:
/* cut off */
phpstr_reset(PHPSTR(s->stream.opaque));
}
return SUCCESS;
- break;
case Z_DATA_ERROR:
/* raw deflated data ? */
inflateInit2(&s->stream, HTTP_WINDOW_BITS_RAW);
goto retry_raw_inflate;
}
- break;
}
http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Failed to update inflate stream: %s", zError(status));
s->stream.avail_out = *encoded_len;
s->stream.next_out = (Bytef *) *encoded;
- switch (status = deflate(&s->stream, Z_FULL_FLUSH))
- {
+ switch (status = deflate(&s->stream, Z_FULL_FLUSH)) {
case Z_OK:
case Z_STREAM_END:
*encoded_len = HTTP_DEFLATE_BUFFER_SIZE - s->stream.avail_out;
*encoded = erealloc_rel(*encoded, *encoded_len + 1);
(*encoded)[*encoded_len] = '\0';
return SUCCESS;
- break;
}
STR_SET(*encoded, NULL);
HTTP_G->send.deflate.encoding = !0;
- switch (http_encoding_response_start(0))
- {
+ switch (http_encoding_response_start(0)) {
case HTTP_ENCODING_GZIP:
flags = HTTP_DEFLATE_TYPE_GZIP;
- break;
+ break;
case HTTP_ENCODING_DEFLATE:
flags = HTTP_DEFLATE_TYPE_ZLIB;
- break;
+ break;
default:
goto deflate_passthru_plain;
- break;
}
flags |= (HTTP_G->send.deflate.start_flags &~ 0xf0);
{
zend_class_entry *ex = http_exception_object_ce;
- switch (code)
- {
+ switch (code) {
case HTTP_E_RUNTIME: ex = HTTP_EX_CE(runtime); break;
case HTTP_E_INVALID_PARAM: ex = HTTP_EX_CE(invalid_param); break;
case HTTP_E_HEADER: ex = HTTP_EX_CE(header); break;
HTTP_FILTER_BUFFER(deflate) *b = NULL;
if (params) {
- switch (Z_TYPE_P(params))
- {
+ switch (Z_TYPE_P(params)) {
case IS_ARRAY:
case IS_OBJECT:
if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) {
FREE_ZVAL(params);
}
- switch (status)
- {
+ switch (status) {
case 300:
RETVAL_SUCCESS(http_send_status_header(status, LOC));
efree(LOC);
return;
- break;
case HTTP_REDIRECT_PERM:
case HTTP_REDIRECT_FOUND:
case HTTP_REDIRECT_POST:
case HTTP_REDIRECT_PROXY:
case HTTP_REDIRECT_TEMP:
- break;
+ break;
case 306:
default:
} else {
status = HTTP_REDIRECT_FOUND;
}
- break;
+ break;
}
RETURN_SUCCESS(http_exit_ex(status, LOC, RED, 1));
RETURN_FALSE;
}
- switch (body.type)
- {
+ switch (body.type) {
case HTTP_REQUEST_BODY_CURLPOST:
if (CURLE_OK != (rc = Curl_getFormData(&data, body.data, &size))) {
http_error_ex(HE_WARNING, HTTP_E_RUNTIME, "Could not encode request body: %s", curl_easy_strerror(rc));
}
}
http_request_body_dtor(&body);
- break;
+ break;
case HTTP_REQUEST_BODY_CSTRING:
RETVAL_STRINGL(body.data, body.size, 0);
- break;
+ break;
default:
http_request_body_dtor(&body);
RETVAL_FALSE;
- break;
+ break;
}
}
#endif /* HTTP_HAVE_CURL */
RETURN_FALSE;
}
- switch (Z_TYPE_P(method))
- {
+ switch (Z_TYPE_P(method)) {
case IS_OBJECT:
convert_to_string(method);
case IS_STRING:
RETURN_FALSE;
}
- switch (Z_TYPE_P(method))
- {
+ switch (Z_TYPE_P(method)) {
case IS_OBJECT:
convert_to_string(method);
case IS_STRING:
range += sizeof("bytes=") - 1;
do {
- switch (c = *(range++))
- {
+ switch (c = *(range++)) {
case '0':
/* allow 000... - shall we? */
if (*ptr != -10) {
*ptr *= 10;
}
- break;
+ break;
case '1': case '2': case '3':
case '4': case '5': case '6':
} else {
*ptr = c - '0';
}
- break;
+ break;
case '-':
ptr = &end;
- break;
+ break;
case ' ':
- /* IE - ignore for now */
- break;
+ break;
case 0:
case ',':
if (length) {
/* validate ranges */
- switch (begin)
- {
+ switch (begin) {
/* "0-12345" */
case -10:
/* "0-" */
return RANGE_ERR;
}
begin = 0;
- break;
+ break;
/* "-12345" */
case -1:
}
begin = length - end;
end = length - 1;
- break;
+ break;
/* "12345-(xxx)" */
default:
- switch (end)
- {
+ switch (end) {
/* "12345-0" */
case -10:
return RANGE_ERR;
- break;
/* "12345-" */
case -1:
return RANGE_ERR;
}
end = length - 1;
- break;
+ break;
/* "12345-67890" */
default:
(end < begin)) {
return RANGE_ERR;
}
- break;
+ break;
}
- break;
+ break;
}
}
{
end = -1;
ptr = &begin;
}
- break;
+ break;
default:
return RANGE_NO;
- break;
}
} while (c != 0);
do {
int value_len = 0;
- switch (*line++)
- {
+ switch (*line++) {
case ':':
if (!colon) {
colon = line - 1;
}
- break;
+ break;
case 0:
--value_len; /* we don't have CR so value length is one char less */
value_len = 0;
header += line - header;
}
- break;
+ break;
}
} while (MORE_HEADERS);
INIT_ZARR(array, *headers);
- switch (info->type)
- {
+ switch (info->type) {
case IS_HTTP_REQUEST:
add_assoc_string(&array, "Request Method", HTTP_INFO(info).request.method, 1);
add_assoc_string(&array, "Request Url", HTTP_INFO(info).request.url, 1);
- break;
+ break;
case IS_HTTP_RESPONSE:
add_assoc_long(&array, "Response Code", (long) HTTP_INFO(info).response.code);
add_assoc_string(&array, "Response Status", HTTP_INFO(info).response.status, 1);
- break;
+ break;
}
}
PHP_HTTP_API void _http_info_dtor(http_info *i)
{
- switch (i->type)
- {
+ switch (i->type) {
case IS_HTTP_REQUEST:
STR_SET(HTTP_INFO(i).request.method, NULL);
STR_SET(HTTP_INFO(i).request.url, NULL);
- break;
+ break;
case IS_HTTP_RESPONSE:
STR_SET(HTTP_INFO(i).response.status, NULL);
- break;
+ break;
default:
- break;
+ break;
}
}
{
message->http.version = .0;
- switch (message->type = type)
- {
+ switch (message->type = type) {
case HTTP_MSG_RESPONSE:
message->http.info.response.code = 0;
message->http.info.response.status = NULL;
- break;
+ break;
case HTTP_MSG_REQUEST:
message->http.info.request.method = NULL;
message->http.info.request.url = NULL;
- break;
+ break;
case HTTP_MSG_NONE:
default:
- break;
+ break;
}
}
if (type != message->type) {
/* free request info */
- switch (message->type)
- {
+ switch (message->type) {
case HTTP_MSG_REQUEST:
STR_FREE(message->http.info.request.method);
STR_FREE(message->http.info.request.url);
- break;
+ break;
case HTTP_MSG_RESPONSE:
STR_FREE(message->http.info.response.status);
- break;
+ break;
default:
- break;
+ break;
}
/* init */
{
message->http.version = info->http.version;
- switch (message->type = info->type)
- {
+ switch (message->type = info->type) {
case IS_HTTP_REQUEST:
HTTP_INFO(message).request.url = estrdup(HTTP_INFO(info).request.url);
STR_SET(HTTP_INFO(message).request.method, estrdup(HTTP_INFO(info).request.method));
- break;
+ break;
case IS_HTTP_RESPONSE:
HTTP_INFO(message).response.code = HTTP_INFO(info).response.code;
STR_SET(HTTP_INFO(message).response.status, estrdup(HTTP_INFO(info).response.status));
- break;
+ break;
default:
- break;
+ break;
}
}
phpstr_init_ex(&str, 4096, 0);
- switch (msg->type)
- {
+ switch (msg->type) {
case HTTP_MSG_REQUEST:
phpstr_appendf(&str, "%s %s HTTP/%1.1f" HTTP_CRLF,
msg->http.info.request.method,
msg->http.info.request.url,
msg->http.version);
- break;
+ break;
case HTTP_MSG_RESPONSE:
phpstr_appendf(&str, "HTTP/%1.1f %d%s%s" HTTP_CRLF,
msg->http.info.response.code,
*msg->http.info.response.status ? " ":"",
msg->http.info.response.status);
- break;
+ break;
case HTTP_MSG_NONE:
default:
- break;
+ break;
}
FOREACH_HASH_KEYVAL(pos1, &msg->hdrs, key, idx, header) {
if (key) {
zval **single_header;
- switch (Z_TYPE_PP(header))
- {
+ switch (Z_TYPE_PP(header)) {
case IS_STRING:
phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key, Z_STRVAL_PP(header));
- break;
+ break;
case IS_ARRAY:
{
FOREACH_VAL(pos2, *header, single_header) {
phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key, Z_STRVAL_PP(single_header));
}
+ break;
}
- break;
}
key = NULL;
{
STATUS rs = FAILURE;
- switch (message->type)
- {
+ switch (message->type) {
case HTTP_MSG_RESPONSE:
{
char *key;
rs = SUCCESS == http_send_status(message->http.info.response.code) &&
SUCCESS == http_send_data(PHPSTR_VAL(message), PHPSTR_LEN(message)) ?
SUCCESS : FAILURE;
+ break;
}
- break;
case HTTP_MSG_REQUEST:
{
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "HTTP requests not supported - ext/http was not linked against libcurl.");
#endif
- }
break;
+ }
case HTTP_MSG_NONE:
default:
http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is neither of type HTTP_MSG_REQUEST nor HTTP_MSG_RESPONSE");
- break;
+ break;
}
return rs;
zend_hash_destroy(&message->hdrs);
phpstr_dtor(PHPSTR(message));
- switch (message->type)
- {
+ switch (message->type) {
case HTTP_MSG_REQUEST:
STR_SET(message->http.info.request.method, NULL);
STR_SET(message->http.info.request.url, NULL);
- break;
+ break;
case HTTP_MSG_RESPONSE:
STR_SET(message->http.info.response.status, NULL);
- break;
+ break;
default:
- break;
+ break;
}
}
}
case HTTP_MSG_PROPHASH_TYPE:
case HTTP_MSG_CHILD_PROPHASH_TYPE:
RETVAL_LONG(msg->type);
- break;
+ break;
case HTTP_MSG_PROPHASH_HTTP_VERSION:
case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION:
RETVAL_DOUBLE(msg->http.version);
- break;
+ break;
case HTTP_MSG_PROPHASH_BODY:
case HTTP_MSG_CHILD_PROPHASH_BODY:
phpstr_fix(PHPSTR(msg));
RETVAL_PHPSTR(PHPSTR(msg), 0, 1);
- break;
+ break;
case HTTP_MSG_PROPHASH_HEADERS:
case HTTP_MSG_CHILD_PROPHASH_HEADERS:
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;
+ break;
case HTTP_MSG_PROPHASH_PARENT_MESSAGE:
case HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE:
} else {
RETVAL_NULL();
}
- break;
+ break;
case HTTP_MSG_PROPHASH_REQUEST_METHOD:
case HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD:
} else {
RETVAL_NULL();
}
- break;
+ break;
case HTTP_MSG_PROPHASH_REQUEST_URL:
case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL:
} else {
RETVAL_NULL();
}
- break;
+ break;
case HTTP_MSG_PROPHASH_RESPONSE_CODE:
case HTTP_MSG_CHILD_PROPHASH_RESPONSE_CODE:
} else {
RETVAL_NULL();
}
- break;
+ break;
case HTTP_MSG_PROPHASH_RESPONSE_STATUS:
case HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS:
} else {
RETVAL_NULL();
}
- break;
+ break;
default:
#ifdef WONKY
#else
RETVAL_NULL();
#endif
- break;
}
return return_value;
case HTTP_MSG_CHILD_PROPHASH_TYPE:
convert_to_long(cpy);
http_message_set_type(msg, Z_LVAL_P(cpy));
- break;
+ break;
case HTTP_MSG_PROPHASH_HTTP_VERSION:
case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION:
convert_to_double(cpy);
msg->http.version = Z_DVAL_P(cpy);
- break;
+ break;
case HTTP_MSG_PROPHASH_BODY:
case HTTP_MSG_CHILD_PROPHASH_BODY:
convert_to_string(cpy);
phpstr_dtor(PHPSTR(msg));
phpstr_from_string_ex(PHPSTR(msg), Z_STRVAL_P(cpy), Z_STRLEN_P(cpy));
- break;
+ break;
case HTTP_MSG_PROPHASH_HEADERS:
case HTTP_MSG_CHILD_PROPHASH_HEADERS:
convert_to_array(cpy);
zend_hash_clean(&msg->hdrs);
zend_hash_copy(&msg->hdrs, Z_ARRVAL_P(cpy), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
- break;
+ break;
case HTTP_MSG_PROPHASH_PARENT_MESSAGE:
case HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE:
Z_OBJ_ADDREF_P(value);
obj->parent = value->value.obj;
}
- break;
+ break;
case HTTP_MSG_PROPHASH_REQUEST_METHOD:
case HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD:
convert_to_string(cpy);
STR_SET(msg->http.info.request.method, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy)));
}
- break;
+ break;
case HTTP_MSG_PROPHASH_REQUEST_URL:
case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL:
convert_to_string(cpy);
STR_SET(msg->http.info.request.url, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy)));
}
- break;
+ break;
case HTTP_MSG_PROPHASH_RESPONSE_CODE:
case HTTP_MSG_CHILD_PROPHASH_RESPONSE_CODE:
convert_to_long(cpy);
msg->http.info.response.code = Z_LVAL_P(cpy);
}
- break;
+ break;
case HTTP_MSG_PROPHASH_RESPONSE_STATUS:
case HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS:
convert_to_string(cpy);
STR_SET(msg->http.info.response.status, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy)));
}
- break;
+ break;
default:
#ifdef WONKY
zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC);
#endif
- break;
+ break;
}
zval_free(&cpy);
}
ASSOC_PROP(array, long, "type", msg->type);
ASSOC_PROP(array, double, "httpVersion", msg->http.version);
- switch (msg->type)
- {
+ switch (msg->type) {
case HTTP_MSG_REQUEST:
ASSOC_PROP(array, long, "responseCode", 0);
ASSOC_STRINGL(array, "responseStatus", "", 0);
ASSOC_STRING(array, "requestMethod", msg->http.info.request.method);
ASSOC_STRING(array, "requestUrl", msg->http.info.request.url);
- break;
+ break;
case HTTP_MSG_RESPONSE:
ASSOC_PROP(array, long, "responseCode", msg->http.info.response.code);
ASSOC_STRING(array, "responseStatus", msg->http.info.response.status);
ASSOC_STRINGL(array, "requestMethod", "", 0);
ASSOC_STRINGL(array, "requestUrl", "", 0);
- break;
+ break;
case HTTP_MSG_NONE:
default:
ASSOC_STRINGL(array, "responseStatus", "", 0);
ASSOC_STRINGL(array, "requestMethod", "", 0);
ASSOC_STRINGL(array, "requestUrl", "", 0);
- break;
+ break;
}
MAKE_STD_ZVAL(headers);
if (return_value_used) {
getObject(http_message_object, obj);
- switch (obj->message->type)
- {
+ switch (obj->message->type) {
case HTTP_MSG_REQUEST:
{
#ifdef HTTP_HAVE_CURL
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpRequest (missing curl support)");
#endif
+ break;
}
- break;
case HTTP_MSG_RESPONSE:
{
INIT_PZVAL(&zkey);
ZVAL_STRINGL(&zkey, key, key_len, 0);
- switch (Z_TYPE_PP(header))
- {
+ switch (Z_TYPE_PP(header)) {
case IS_ARRAY:
case IS_OBJECT:
FOREACH_HASH_VAL(pos2, HASH_OF(*header), h) {
zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *h);
zval_ptr_dtor(h);
}
- break;
+ break;
default:
ZVAL_ADDREF(*header);
zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *header);
zval_ptr_dtor(header);
- break;
+ break;
}
key = NULL;
}
#else
http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpResponse (need PHP 5.1+)");
#endif
+ break;
}
- break;
default:
http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is neither of type HttpMessage::TYPE_REQUEST nor HttpMessage::TYPE_RESPONSE");
- break;
+ break;
}
}
SET_EH_NORMAL();
if (Z_TYPE_P(ztype) == IS_LONG) {
type = Z_LVAL_P(ztype);
} else if(Z_TYPE_P(ztype) == IS_STRING) {
- switch (Z_STRVAL_P(ztype)[0])
- {
+ switch (Z_STRVAL_P(ztype)[0]) {
case 'B':
case 'b': type = HTTP_QUERYSTRING_TYPE_BOOL; break;
case 'I':
}
/* request method */
- switch (request->meth)
- {
+ switch (request->meth) {
case HTTP_GET:
HTTP_CURL_OPT(CURLOPT_HTTPGET, 1);
- break;
+ break;
case HTTP_HEAD:
HTTP_CURL_OPT(CURLOPT_NOBODY, 1);
- break;
+ break;
case HTTP_POST:
HTTP_CURL_OPT(CURLOPT_POST, 1);
- break;
+ break;
case HTTP_PUT:
HTTP_CURL_OPT(CURLOPT_UPLOAD, 1);
- break;
+ break;
default:
if (http_request_method_exists(0, request->meth, NULL)) {
http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Unsupported request method: %d (%s)", request->meth, request->url);
return FAILURE;
}
- break;
+ break;
}
/* attach request body */
if (request->body && (request->meth != HTTP_GET) && (request->meth != HTTP_HEAD) && (request->meth != HTTP_OPTIONS)) {
- switch (request->body->type)
- {
+ switch (request->body->type) {
case HTTP_REQUEST_BODY_EMPTY:
/* nothing */
- break;
+ break;
case HTTP_REQUEST_BODY_CURLPOST:
HTTP_CURL_OPT(CURLOPT_HTTPPOST, (struct curl_httppost *) request->body->data);
- break;
+ break;
case HTTP_REQUEST_BODY_CSTRING:
if (request->meth != HTTP_PUT) {
HTTP_CURL_OPT(CURLOPT_IOCTLDATA, request);
HTTP_CURL_OPT(CURLOPT_READDATA, request);
HTTP_CURL_OPT(CURLOPT_INFILESIZE, request->body->size);
- break;
+ break;
default:
/* shouldn't ever happen */
http_error_ex(HE_ERROR, 0, "Unknown request body type: %d (%s)", request->body->type, request->url);
return FAILURE;
- break;
}
}
TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
if (request->body) {
- switch (request->body->type)
- {
+ switch (request->body->type) {
case HTTP_REQUEST_BODY_CSTRING:
{
size_t out = MIN(len * n, request->body->size - request->body->priv);
request->body->priv += out;
return out;
}
+ break;
}
- break;
case HTTP_REQUEST_BODY_UPLOADFILE:
return php_stream_read((php_stream *) request->body->data, data, len * n);
- break;
}
}
return 0;
}
if (request->body) {
- switch (request->body->type)
- {
+ switch (request->body->type) {
case HTTP_REQUEST_BODY_CSTRING:
request->body->priv = 0;
return CURLIOE_OK;
- break;
+ break;
case HTTP_REQUEST_BODY_UPLOADFILE:
if (SUCCESS == php_stream_rewind((php_stream *) request->body->data)) {
return CURLIOE_OK;
}
- break;
+ break;
}
}
{
http_request *request = (http_request *) ctx;
- switch (type)
- {
+ switch (type) {
case CURLINFO_DATA_IN:
if (request->conv.last_type == CURLINFO_HEADER_IN) {
phpstr_appends(&request->conv.response, HTTP_CRLF);
}
case CURLINFO_HEADER_IN:
phpstr_append(&request->conv.response, data, length);
- break;
+ break;
case CURLINFO_DATA_OUT:
if (request->conv.last_type == CURLINFO_HEADER_OUT) {
phpstr_appends(&request->conv.request, HTTP_CRLF);
}
case CURLINFO_HEADER_OUT:
phpstr_append(&request->conv.request, data, length);
- break;
+ break;
default:
#if 0
fprintf(stderr, "## ", type);
fprintf(stderr, "\n");
}
#endif
- break;
+ break;
}
if (type) {
{
if (body) {
if (body->free) {
- switch (body->type)
- {
+ switch (body->type) {
case HTTP_REQUEST_BODY_CSTRING:
if (body->data) {
efree(body->data);
}
- break;
+ break;
case HTTP_REQUEST_BODY_CURLPOST:
curl_formfree(body->data);
- break;
+ break;
case HTTP_REQUEST_BODY_UPLOADFILE:
php_stream_close(body->data);
- break;
+ break;
}
}
memset(body, 0, sizeof(http_request_body));
method = emalloc(method_name_len + 1);
mconst = emalloc(method_name_len + 1);
for (i = 0; i < method_name_len; ++i) {
- switch (method_name[i])
- {
+ switch (method_name[i]) {
case '-':
method[i] = '-';
mconst[i] = '_';
- break;
+ break;
default:
if (!isalnum(method_name[i])) {
return 0;
}
mconst[i] = method[i] = toupper(method_name[i]);
- break;
+ break;
}
}
method[method_name_len] = '\0';
{
case HTTP_GET:
case HTTP_HEAD:
- break;
+ break;
case HTTP_PUT:
{
status = FAILURE;
}
}
+ break;
}
- break;
case HTTP_POST:
default:
}
}
}
+ break;
}
- break;
}
if (status == SUCCESS) {
{
zval *data = GET_STATIC_PROP(data);
ct = http_guess_content_type(magic_file, magic_mode, Z_STRVAL_P(data), Z_STRLEN_P(data), SEND_DATA);
+ break;
}
- break;
case SEND_RSRC:
{
z->type = IS_RESOURCE;
php_stream_from_zval(s, &z);
ct = http_guess_content_type(magic_file, magic_mode, s, 0, SEND_RSRC);
+ break;
}
- break;
default:
ct = http_guess_content_type(magic_file, magic_mode, Z_STRVAL_P(GET_STATIC_PROP(file)), 0, -1);
- break;
+ break;
}
if (ct) {
UPD_STATIC_PROP(string, contentType, ct);
php_start_ob_buffer(NULL, HTTP_G->send.buffer_size, 0 TSRMLS_CC);
/* send */
- switch (Z_LVAL_P(GET_STATIC_PROP(mode)))
- {
+ switch (Z_LVAL_P(GET_STATIC_PROP(mode))) {
case SEND_DATA:
{
zval *zdata_p, *zdata = convert_to_type_ex(IS_STRING, GET_STATIC_PROP(data), &zdata_p);
char *buf;
long got, len = end - begin;
- switch (mode)
- {
+ switch (mode) {
case SEND_RSRC:
{
php_stream *s = (php_stream *) data;
efree(buf);
}
+ break;
}
- break;
case SEND_DATA:
{
len -= got;
buf += got;
}
+ break;
}
- break;
EMPTY_SWITCH_DEFAULT_CASE();
}
zend_hash_init(&ranges, 0, NULL, ZVAL_PTR_DTOR, 0);
range_status = http_get_request_ranges(&ranges, data_size);
- switch (range_status)
- {
+ switch (range_status) {
case RANGE_ERR:
{
zend_hash_destroy(&ranges);
magic_setflags(magic, magicmode);
- switch (data_mode)
- {
+ switch (data_mode) {
case SEND_RSRC:
{
char *buffer;
b_len = php_stream_copy_to_mem(data_ptr, &buffer, 65536, 0);
ctype = magic_buffer(magic, buffer, b_len);
efree(buffer);
+ break;
}
- break;
case SEND_DATA:
ctype = magic_buffer(magic, data_ptr, data_len);
- break;
+ break;
default:
HTTP_CHECK_OPEN_BASEDIR(data_ptr, magic_close(magic); return NULL);
ctype = magic_file(magic, data_ptr);
- break;
+ break;
}
if (ctype) {
if (!(flags & HTTP_URL_STRIP_PORT)) {
url->port = (new_url&&new_url->port) ? new_url->port : ((old_url) ? old_url->port : 0);
}
- if ((!(flags & HTTP_URL_STRIP_AUTH)) && (!(flags & HTTP_URL_STRIP_USER))) {
+ if (!(flags & HTTP_URL_STRIP_USER)) {
__URLCPY(user);
}
- if ((!(flags & HTTP_URL_STRIP_AUTH)) && (!(flags & HTTP_URL_STRIP_PASS))) {
+ if (!(flags & HTTP_URL_STRIP_PASS)) {
__URLCPY(pass);
}
zval *https = http_get_server_var("HTTPS");
if (https && !strcasecmp(Z_STRVAL_P(https), "ON")) {
url->scheme = estrndup("https", lenof("https"));
- } else
- switch (url->port)
- {
+ } else switch (url->port) {
case 443:
url->scheme = estrndup("https", lenof("https"));
- break;
+ break;
#ifndef HTTP_HAVE_NETDB
default:
#endif
case 80:
url->scheme = estrndup("http", lenof("http"));
- break;
+ break;
#ifdef HTTP_HAVE_NETDB
default:
} else {
url->scheme = estrndup("http", lenof("http"));
}
- break;
+ break;
#endif
}
}
char *ptr, *end = url->path + strlen(url->path) + 1;
for (ptr = strstr(url->path, "/."); ptr; ptr = strstr(ptr, "/.")) {
- switch (ptr[2])
- {
+ switch (ptr[2]) {
case '\0':
ptr[1] = '\0';
- break;
+ break;
case '/':
memmove(&ptr[1], &ptr[3], end - &ptr[3]);
- break;
+ break;
case '.':
if (ptr[3] == '/') {
}
memmove(&ptr[1], pos, end - pos);
}
- break;
+ break;
default:
/* something else */
++ptr;
- break;
+ break;
}
}
}
static inline zval *_convert_to_type(int type, zval *z)
{
if (Z_TYPE_P(z) != type) {
- switch (type)
- {
+ switch (type) {
case IS_NULL: convert_to_null(z); break;
case IS_BOOL: convert_to_boolean(z); break;
case IS_LONG: convert_to_long(z); break;
{
*p = z;
if (Z_TYPE_P(z) != type) {
- switch (type)
- {
+ switch (type) {
case IS_NULL: convert_to_null_ex(&z); break;
case IS_BOOL: convert_to_boolean_ex(&z); break;
case IS_LONG: convert_to_long_ex(&z); break;
#define HTTP_URL_JOIN_QUERY 0x002
#define HTTP_URL_STRIP_USER 0x004
#define HTTP_URL_STRIP_PASS 0x008
-#define HTTP_URL_STRIP_AUTH 0x010
+#define HTTP_URL_STRIP_AUTH (HTTP_URL_STRIP_USER|HTTP_URL_STRIP_PASS)
#define HTTP_URL_STRIP_PORT 0x020
#define HTTP_URL_STRIP_PATH 0x040
#define HTTP_URL_STRIP_QUERY 0x080
zval arr;
if (strct) {
- switch (Z_TYPE_P(strct))
- {
+ switch (Z_TYPE_P(strct)) {
default:
zval_dtor(strct);
array_init(strct);