projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
- some minor strlen() and strlcat() tweaks
[m6w6/ext-http]
/
http_request_object.c
diff --git
a/http_request_object.c
b/http_request_object.c
index cbb8b2be93b0810b521c174a54b9c597021b8898..37e2a58bd75c031f3b8a11828ca75ecf647b2eac 100644
(file)
--- a/
http_request_object.c
+++ b/
http_request_object.c
@@
-424,10
+424,7
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
if (!body) {
return FAILURE;
}
if (!body) {
return FAILURE;
}
- if ((!obj->ch) && (!(obj->ch = curl_easy_init()))) {
- http_error(HE_WARNING, HTTP_E_REQUEST, "Could not initilaize curl");
- return FAILURE;
- }
+ HTTP_CHECK_CURL_INIT(obj->ch, curl_easy_init(), return FAILURE);
URL = convert_to_type_ex(IS_STRING, GET_PROP(obj, url));
// HTTP_URI_MAXLEN+1 long char *
URL = convert_to_type_ex(IS_STRING, GET_PROP(obj, url));
// HTTP_URI_MAXLEN+1 long char *
@@
-504,13
+501,13
@@
STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
if (status == SUCCESS) {
zval *qdata = convert_to_type_ex(IS_STRING, GET_PROP(obj, queryData));
if (status == SUCCESS) {
zval *qdata = convert_to_type_ex(IS_STRING, GET_PROP(obj, queryData));
- if (Z_STRLEN_P(qdata)
&& (strlen(request_uri) < HTTP_URI_MAXLEN)
) {
+ if (Z_STRLEN_P(qdata)) {
if (!strchr(request_uri, '?')) {
if (!strchr(request_uri, '?')) {
- str
cat(request_uri, "?"
);
+ str
lcat(request_uri, "?", HTTP_URI_MAXLEN
);
} else {
} else {
- str
cat(request_uri, "&"
);
+ str
lcat(request_uri, "&", HTTP_URI_MAXLEN
);
}
}
- str
ncat(request_uri, Z_STRVAL_P(qdata), HTTP_URI_MAXLEN - strlen(request_uri)
);
+ str
lcat(request_uri, Z_STRVAL_P(qdata), HTTP_URI_MAXLEN
);
}
status = http_request_init(obj->ch, Z_LVAL_P(meth), request_uri, body, Z_ARRVAL_P(GET_PROP(obj, options)));
}
status = http_request_init(obj->ch, Z_LVAL_P(meth), request_uri, body, Z_ARRVAL_P(GET_PROP(obj, options)));
@@
-1033,11
+1030,7
@@
PHP_METHOD(HttpRequest, setContentType)
RETURN_FALSE;
}
RETURN_FALSE;
}
- if (!strchr(ctype, '/')) {
- http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Content-Type '%s' doesn't seem to contain a primary and a secondary part", ctype);
- RETURN_FALSE;
- }
-
+ HTTP_CHECK_CONTENT_TYPE(ctype, RETURN_FALSE);
UPD_STRL(obj, contentType, ctype, ct_len);
RETURN_TRUE;
}
UPD_STRL(obj, contentType, ctype, ct_len);
RETURN_TRUE;
}
@@
-1341,10
+1334,7
@@
PHP_METHOD(HttpRequest, addPostFile)
}
if (type_len) {
}
if (type_len) {
- if (!strchr(type, '/')) {
- http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Content-Type '%s' doesn't seem to contain a primary and a secondary part", type);
- RETURN_FALSE;
- }
+ HTTP_CHECK_CONTENT_TYPE(type, RETURN_FALSE);
} else {
type = "application/x-octetstream";
type_len = sizeof("application/x-octetstream") - 1;
} else {
type = "application/x-octetstream";
type_len = sizeof("application/x-octetstream") - 1;