* use the separator where applicable
[m6w6/ext-http] / php_http_message_body.c
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2010, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id: http_message_body.c 292841 2009-12-31 08:48:57Z mike $ */
14
15 #include "php_http.h"
16
17 #include <libgen.h>
18 #include <ext/standard/php_lcg.h>
19 #include <ext/standard/php_string.h>
20
21 #define BOUNDARY_OPEN(body) \
22 do {\
23 size_t size = php_http_message_body_size(body); \
24 if (size) { \
25 php_stream_truncate_set_size(php_http_message_body_stream(body), size - lenof("--" PHP_HTTP_CRLF)); \
26 php_http_message_body_append(body, ZEND_STRL(PHP_HTTP_CRLF)); \
27 } else { \
28 php_http_message_body_appendf(body, "--%s" PHP_HTTP_CRLF, php_http_message_body_boundary(body)); \
29 } \
30 } while(0)
31 #define BOUNDARY_CLOSE(body) \
32 php_http_message_body_appendf(body, PHP_HTTP_CRLF "--%s--" PHP_HTTP_CRLF, php_http_message_body_boundary(body))
33
34 static STATUS add_recursive_fields(php_http_message_body_t *body, const char *name, zval *value);
35 static STATUS add_recursive_files(php_http_message_body_t *body, const char *name, zval *value);
36
37 PHP_HTTP_API php_http_message_body_t *php_http_message_body_init(php_http_message_body_t *body, php_stream *stream TSRMLS_DC)
38 {
39 if (!body) {
40 body = emalloc(sizeof(php_http_message_body_t));
41 }
42 memset(body, 0, sizeof(*body));
43
44 if (stream) {
45 php_stream_auto_cleanup(stream);
46 body->stream_id = php_stream_get_resource_id(stream);
47 zend_list_addref(body->stream_id);
48 } else {
49 stream = php_stream_temp_create(TEMP_STREAM_DEFAULT, 0xffff);
50 php_stream_auto_cleanup(stream);
51 body->stream_id = php_stream_get_resource_id(stream);
52 }
53 TSRMLS_SET_CTX(body->ts);
54
55 return body;
56 }
57
58 PHP_HTTP_API php_http_message_body_t *php_http_message_body_copy(php_http_message_body_t *from, php_http_message_body_t *to, zend_bool dup_internal_stream_and_contents)
59 {
60 if (!from) {
61 return NULL;
62 } else {
63 TSRMLS_FETCH_FROM_CTX(from->ts);
64
65 if (dup_internal_stream_and_contents) {
66 to = php_http_message_body_init(to, NULL TSRMLS_CC);
67 php_http_message_body_to_stream(from, php_http_message_body_stream(to), 0, 0);
68 } else {
69 to = php_http_message_body_init(to, php_http_message_body_stream(from) TSRMLS_CC);
70 }
71
72 if (from->boundary) {
73 to->boundary = estrdup(from->boundary);
74 }
75
76 return to;
77 }
78 }
79
80 PHP_HTTP_API void php_http_message_body_dtor(php_http_message_body_t *body)
81 {
82 /* NO FIXME: shows leakinfo in DEBUG mode */
83 zend_list_delete(body->stream_id);
84 STR_FREE(body->boundary);
85 }
86
87 PHP_HTTP_API void php_http_message_body_free(php_http_message_body_t **body)
88 {
89 if (*body) {
90 php_http_message_body_dtor(*body);
91 efree(*body);
92 *body = NULL;
93 }
94 }
95
96 PHP_HTTP_API const php_stream_statbuf *php_http_message_body_stat(php_http_message_body_t *body)
97 {
98 TSRMLS_FETCH_FROM_CTX(body->ts);
99 php_stream_stat(php_http_message_body_stream(body), &body->ssb);
100 return &body->ssb;
101 }
102
103 PHP_HTTP_API const char *php_http_message_body_boundary(php_http_message_body_t *body)
104 {
105 if (!body->boundary) {
106 union { double dbl; int num[2]; } data;
107 TSRMLS_FETCH_FROM_CTX(body->ts);
108
109 data.dbl = php_combined_lcg(TSRMLS_C);
110 spprintf(&body->boundary, 0, "%x.%x", data.num[0], data.num[1]);
111 }
112 return body->boundary;
113 }
114
115 PHP_HTTP_API char *php_http_message_body_etag(php_http_message_body_t *body)
116 {
117 TSRMLS_FETCH_FROM_CTX(body->ts);
118 php_stream_statbuf *ssb = php_http_message_body_stat(body);
119
120 /* real file or temp buffer ? */
121 if (body->ssb.sb.st_mtime) {
122 char *etag;
123
124 spprintf(&etag, 0, "%lx-%lx-%lx", ssb->sb.st_ino, ssb->sb.st_mtime, ssb->sb.st_size);
125 return etag;
126 } else {
127 void *ctx = php_http_etag_init(TSRMLS_C);
128
129 php_http_message_body_to_callback(body, php_http_etag_update, ctx, 0, 0);
130 return php_http_etag_finish(ctx TSRMLS_CC);
131 }
132 }
133
134 PHP_HTTP_API void php_http_message_body_to_string(php_http_message_body_t *body, char **buf, size_t *len, off_t offset, size_t forlen)
135 {
136 TSRMLS_FETCH_FROM_CTX(body->ts);
137 php_stream *s = php_http_message_body_stream(body);
138
139 php_stream_seek(s, offset, SEEK_SET);
140 if (!forlen) {
141 forlen = -1;
142 }
143 *len = php_stream_copy_to_mem(s, buf, forlen, 0);
144 }
145
146 PHP_HTTP_API void php_http_message_body_to_stream(php_http_message_body_t *body, php_stream *dst, off_t offset, size_t forlen)
147 {
148 TSRMLS_FETCH_FROM_CTX(body->ts);
149 php_stream *s = php_http_message_body_stream(body);
150
151 php_stream_seek(s, offset, SEEK_SET);
152 if (!forlen) {
153 forlen = -1;
154 }
155 php_stream_copy_to_stream_ex(s, dst, forlen, NULL);
156 }
157
158 PHP_HTTP_API void php_http_message_body_to_callback(php_http_message_body_t *body, php_http_pass_callback_t cb, void *cb_arg, off_t offset, size_t forlen)
159 {
160 TSRMLS_FETCH_FROM_CTX(body->ts);
161 php_stream *s = php_http_message_body_stream(body);
162 char *buf = emalloc(0x1000);
163
164 php_stream_seek(s, offset, SEEK_SET);
165
166 if (!forlen) {
167 forlen = -1;
168 }
169 while (!php_stream_eof(s)) {
170 size_t read = php_stream_read(s, buf, MIN(forlen, 0x1000));
171
172 if (read) {
173 cb(cb_arg, buf, read);
174 }
175
176 if (read < MIN(forlen, sizeof(buf))) {
177 break;
178 }
179
180 if (forlen && !(forlen -= read)) {
181 break;
182 }
183 }
184 efree(buf);
185 }
186
187 PHP_HTTP_API size_t php_http_message_body_append(php_http_message_body_t *body, const char *buf, size_t len)
188 {
189 php_stream *s;
190 TSRMLS_FETCH_FROM_CTX(body->ts);
191
192 s = php_http_message_body_stream(body);
193 php_stream_seek(s, 0, SEEK_END);
194 return php_stream_write(s, buf, len);
195 }
196
197 PHP_HTTP_API size_t php_http_message_body_appendf(php_http_message_body_t *body, const char *fmt, ...)
198 {
199 va_list argv;
200 char *print_str;
201 size_t print_len;
202
203 va_start(argv, fmt);
204 print_len = vspprintf(&print_str, 0, fmt, argv);
205 va_end(argv);
206
207 print_len = php_http_message_body_append(body, print_str, print_len);
208 efree(print_str);
209
210 return print_len;
211 }
212
213 PHP_HTTP_API STATUS php_http_message_body_add(php_http_message_body_t *body, HashTable *fields, HashTable *files)
214 {
215 zval tmp;
216 TSRMLS_FETCH_FROM_CTX(body->ts);
217
218 if (fields) {
219 INIT_PZVAL_ARRAY(&tmp, fields);
220 if (SUCCESS != add_recursive_fields(body, NULL, &tmp)) {
221 return FAILURE;
222 }
223 }
224 if (files) {
225 INIT_PZVAL_ARRAY(&tmp, files);
226 if (SUCCESS != add_recursive_files(body, NULL, &tmp)) {
227 return FAILURE;
228 }
229 }
230
231 return SUCCESS;
232 }
233
234
235 PHP_HTTP_API STATUS php_http_message_body_add_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len)
236 {
237 char *safe_name = php_addslashes(estrdup(name), strlen(name), NULL, 1 TSRMLS_CC);
238
239 BOUNDARY_OPEN(body);
240 php_http_message_body_appendf(
241 body,
242 "Content-Disposition: form-data; name=\"%s\"" PHP_HTTP_CRLF
243 "" PHP_HTTP_CRLF,
244 safe_name);
245 php_http_message_body_append(body, value_str, value_len);
246 BOUNDARY_CLOSE(body);
247
248 efree(safe_name);
249 return SUCCESS;
250 }
251
252 PHP_HTTP_API STATUS php_http_message_body_add_file(php_http_message_body_t *body, const char *name, const char *path, const char *ctype)
253 {
254 php_stream *in;
255 char *path_dup = estrdup(path);
256 TSRMLS_FETCH_FROM_CTX(body->ts);
257
258 if ((in = php_stream_open_wrapper(path_dup, "r", REPORT_ERRORS|USE_PATH|STREAM_MUST_SEEK, NULL))) {
259 php_stream_statbuf ssb = {{0}};
260
261 if (SUCCESS == php_stream_stat(in, &ssb) && S_ISREG(ssb.sb.st_mode)) {
262 char *safe_name = php_addslashes(estrdup(name), strlen(name), NULL, 1 TSRMLS_CC);
263
264 BOUNDARY_OPEN(body);
265 php_http_message_body_appendf(
266 body,
267 "Content-Disposition: attachment; name=\"%s\"; filename=\"%s\"" PHP_HTTP_CRLF
268 "Content-Type: %s" PHP_HTTP_CRLF
269 "Content-Length: %zu" PHP_HTTP_CRLF
270 "" PHP_HTTP_CRLF,
271 safe_name, basename(path_dup), ctype, ssb.sb.st_size);
272 php_stream_copy_to_stream_ex(in, php_http_message_body_stream(body), PHP_STREAM_COPY_ALL, NULL);
273 BOUNDARY_CLOSE(body);
274
275 efree(safe_name);
276 efree(path_dup);
277 php_stream_close(in);
278 return SUCCESS;
279 } else {
280 efree(path_dup);
281 php_stream_close(in);
282 php_http_error(HE_WARNING, PHP_HTTP_E_MESSAGE_BODY, "Not a valid regular file: %s", path);
283 return FAILURE;
284 }
285 } else {
286 efree(path_dup);
287 return FAILURE;
288 }
289
290 }
291
292 static inline char *format_key(uint type, char *str, ulong num, const char *prefix) {
293 char *new_key = NULL;
294
295 if (prefix && *prefix) {
296 if (type == HASH_KEY_IS_STRING) {
297 spprintf(&new_key, 0, "%s[%s]", prefix, str);
298 } else {
299 spprintf(&new_key, 0, "%s[%lu]", prefix, num);
300 }
301 } else if (type == HASH_KEY_IS_STRING) {
302 new_key = estrdup(str);
303 } else {
304 spprintf(&new_key, 0, "%lu", num);
305 }
306
307 return new_key;
308 }
309
310 static STATUS add_recursive_fields(php_http_message_body_t *body, const char *name, zval *value)
311 {
312 if (Z_TYPE_P(value) == IS_ARRAY || Z_TYPE_P(value) == IS_OBJECT) {
313 zval **val;
314 HashPosition pos;
315 php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
316
317 if (!HASH_OF(value)->nApplyCount) {
318 ++HASH_OF(value)->nApplyCount;
319 FOREACH_KEYVAL(pos, value, key, val) {
320 char *str = format_key(key.type, key.str, key.num, name);
321 if (SUCCESS != add_recursive_fields(body, str, *val)) {
322 efree(str);
323 HASH_OF(value)->nApplyCount--;
324 return FAILURE;
325 }
326 efree(str);
327 }
328 --HASH_OF(value)->nApplyCount;
329 }
330 } else {
331 zval *cpy = php_http_ztyp(IS_STRING, value);
332 php_http_message_body_add_field(body, name, Z_STRVAL_P(cpy), Z_STRLEN_P(cpy));
333 zval_ptr_dtor(&cpy);
334 }
335
336 return SUCCESS;
337 }
338
339 static STATUS add_recursive_files(php_http_message_body_t *body, const char *name, zval *value)
340 {
341 if (Z_TYPE_P(value) == IS_ARRAY || Z_TYPE_P(value) == IS_OBJECT) {
342 zval **zfile, **zname, **ztype;
343
344 if ((SUCCESS == zend_hash_find(HASH_OF(value), ZEND_STRS("name"), (void *) &zname))
345 && (SUCCESS == zend_hash_find(HASH_OF(value), ZEND_STRS("file"), (void *) &zfile))
346 && (SUCCESS == zend_hash_find(HASH_OF(value), ZEND_STRS("type"), (void *) &ztype))
347 ) {
348 zval *zfc = php_http_ztyp(IS_STRING, *zfile), *znc = php_http_ztyp(IS_STRING, *zname), *ztc = php_http_ztyp(IS_STRING, *ztype);
349 char *str = format_key(HASH_KEY_IS_STRING, Z_STRVAL_P(znc), 0, name);
350 STATUS ret = php_http_message_body_add_file(body, str, Z_STRVAL_P(zfc), Z_STRVAL_P(ztc));
351
352 efree(str);
353 zval_ptr_dtor(&znc);
354 zval_ptr_dtor(&zfc);
355 zval_ptr_dtor(&ztc);
356
357 if (ret != SUCCESS) {
358 return ret;
359 }
360 } else {
361 zval **val;
362 HashPosition pos;
363 php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
364
365 if (!HASH_OF(value)->nApplyCount) {
366 ++HASH_OF(value)->nApplyCount;
367 FOREACH_KEYVAL(pos, value, key, val) {
368 char *str = format_key(key.type, key.str, key.num, name);
369 if (SUCCESS != add_recursive_files(body, str, *val)) {
370 efree(str);
371 --HASH_OF(value)->nApplyCount;
372 return FAILURE;
373 }
374 efree(str);
375 }
376 --HASH_OF(value)->nApplyCount;
377 }
378 }
379 } else {
380 php_http_error(HE_WARNING, PHP_HTTP_E_MESSAGE_BODY, "Unrecognized array format for message body file to add");
381 return FAILURE;
382 }
383
384 return SUCCESS;
385 }
386
387 /* PHP */
388
389 #define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpMessageBody, method, 0, req_args)
390 #define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpMessageBody, method, 0)
391 #define PHP_HTTP_MESSAGE_BODY_ME(method, visibility) PHP_ME(HttpMessageBody, method, PHP_HTTP_ARGS(HttpMessageBody, method), visibility)
392
393 PHP_HTTP_BEGIN_ARGS(__construct, 0)
394 PHP_HTTP_ARG_VAL(stream, 0)
395 PHP_HTTP_END_ARGS;
396
397 PHP_HTTP_EMPTY_ARGS(__toString);
398
399 PHP_HTTP_BEGIN_ARGS(toStream, 1)
400 PHP_HTTP_ARG_VAL(stream, 0)
401 PHP_HTTP_END_ARGS;
402
403 PHP_HTTP_BEGIN_ARGS(toCallback, 1)
404 PHP_HTTP_ARG_VAL(callback, 0)
405 PHP_HTTP_END_ARGS;
406
407 PHP_HTTP_BEGIN_ARGS(append, 1)
408 PHP_HTTP_ARG_VAL(string, 0)
409 PHP_HTTP_END_ARGS;
410
411 PHP_HTTP_BEGIN_ARGS(add, 0)
412 PHP_HTTP_ARG_VAL(fields, 0)
413 PHP_HTTP_ARG_VAL(files, 0)
414 PHP_HTTP_END_ARGS;
415
416
417 zend_class_entry *php_http_message_body_class_entry;
418 zend_function_entry php_http_message_body_method_entry[] = {
419 PHP_HTTP_MESSAGE_BODY_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
420 PHP_HTTP_MESSAGE_BODY_ME(__toString, ZEND_ACC_PUBLIC)
421 PHP_MALIAS(HttpMessageBody, toString, __toString, args_for_HttpMessageBody___toString, ZEND_ACC_PUBLIC)
422 PHP_HTTP_MESSAGE_BODY_ME(toStream, ZEND_ACC_PUBLIC)
423 PHP_HTTP_MESSAGE_BODY_ME(toCallback, ZEND_ACC_PUBLIC)
424 PHP_HTTP_MESSAGE_BODY_ME(append, ZEND_ACC_PUBLIC)
425 PHP_HTTP_MESSAGE_BODY_ME(add, ZEND_ACC_PUBLIC)
426 EMPTY_FUNCTION_ENTRY
427 };
428 static zend_object_handlers php_http_message_body_object_handlers;
429
430 PHP_MINIT_FUNCTION(http_message_body)
431 {
432 PHP_HTTP_REGISTER_CLASS(http\\message, Body, http_message_body, php_http_object_class_entry, 0);
433 php_http_message_body_class_entry->create_object = php_http_message_body_object_new;
434 memcpy(&php_http_message_body_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
435 php_http_message_body_object_handlers.clone_obj = php_http_message_body_object_clone;
436
437 return SUCCESS;
438 }
439
440 zend_object_value php_http_message_body_object_new(zend_class_entry *ce TSRMLS_DC)
441 {
442 return php_http_message_body_object_new_ex(ce, NULL, NULL TSRMLS_CC);
443 }
444
445 zend_object_value php_http_message_body_object_new_ex(zend_class_entry *ce, php_http_message_body_t *body, php_http_message_body_object_t **ptr TSRMLS_DC)
446 {
447 zend_object_value ov;
448 php_http_message_body_object_t *o;
449
450 o = ecalloc(1, sizeof(php_http_message_body_object_t));
451 zend_object_std_init((zend_object *) o, php_http_message_body_class_entry TSRMLS_CC);
452 object_properties_init((zend_object *) o, ce);
453
454 if (ptr) {
455 *ptr = o;
456 }
457
458 if (body) {
459 o->body = body;
460 }
461
462 ov.handle = zend_objects_store_put((zend_object *) o, NULL, php_http_message_body_object_free, NULL TSRMLS_CC);
463 ov.handlers = &php_http_message_body_object_handlers;
464
465 return ov;
466 }
467
468 zend_object_value php_http_message_body_object_clone(zval *object TSRMLS_DC)
469 {
470 zend_object_value new_ov;
471 php_http_message_body_object_t *new_obj = NULL;
472 php_http_message_body_object_t *old_obj = zend_object_store_get_object(object TSRMLS_CC);
473
474 new_ov = php_http_message_body_object_new_ex(old_obj->zo.ce, php_http_message_body_copy(old_obj->body, NULL, 1), &new_obj);
475 zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC);
476
477 return new_ov;
478 }
479
480 void php_http_message_body_object_free(void *object TSRMLS_DC)
481 {
482 php_http_message_body_object_t *obj = object;
483
484 php_http_message_body_free(&obj->body);
485
486 zend_object_std_dtor((zend_object *) obj TSRMLS_CC);
487 efree(obj);
488 }
489
490 PHP_METHOD(HttpMessageBody, __construct)
491 {
492 php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
493 zval *zstream = NULL;
494 php_stream *stream;
495
496 with_error_handling(EH_THROW, php_http_exception_class_entry) {
497 if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r!", &zstream)) {
498 if (zstream) {
499 php_stream_from_zval(stream, &zstream);
500
501 if (stream) {
502 if (obj->body) {
503 php_http_message_body_dtor(obj->body);
504 }
505 obj->body = php_http_message_body_init(obj->body, stream TSRMLS_CC);
506 }
507 }
508 if (!obj->body) {
509 obj->body = php_http_message_body_init(NULL, NULL TSRMLS_CC);
510 }
511 }
512 } end_error_handling();
513 }
514
515 PHP_METHOD(HttpMessageBody, __toString)
516 {
517 if (SUCCESS == zend_parse_parameters_none()) {
518 php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
519 char *str;
520 size_t len;
521
522 php_http_message_body_to_string(obj->body, &str, &len, 0, 0);
523 if (str) {
524 RETURN_STRINGL(str, len, 0);
525 }
526 }
527 RETURN_EMPTY_STRING();
528 }
529
530 PHP_METHOD(HttpMessageBody, toStream)
531 {
532 zval *zstream;
533 long offset = 0, forlen = 0;
534
535 if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ll", &zstream, &offset, &forlen)) {
536 php_stream *stream;
537 php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
538
539 php_stream_from_zval(stream, &zstream);
540 php_http_message_body_to_stream(obj->body, stream, offset, forlen);
541 RETURN_TRUE;
542 }
543 RETURN_FALSE;
544 }
545
546 struct fcd {
547 zval *fcz;
548 zend_fcall_info *fci;
549 zend_fcall_info_cache *fcc;
550 };
551
552 static size_t pass(void *cb_arg, const char *str, size_t len TSRMLS_DC)
553 {
554 struct fcd *fcd = cb_arg;
555 zval *zdata;
556
557 MAKE_STD_ZVAL(zdata);
558 ZVAL_STRINGL(zdata, str, len, 1);
559 if (SUCCESS == zend_fcall_info_argn(fcd->fci TSRMLS_CC, 2, fcd->fcz, zdata)) {
560 zend_fcall_info_call(fcd->fci, fcd->fcc, NULL, NULL TSRMLS_CC);
561 zend_fcall_info_args_clear(fcd->fci, 0);
562 }
563 zval_ptr_dtor(&zdata);
564 return len;
565 }
566
567 PHP_METHOD(HttpMessageBody, toCallback)
568 {
569 struct fcd fcd;
570 long offset = 0, forlen = 0;
571
572 if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f|ll", &fcd.fci, &fcd.fcc, &offset, &forlen)) {
573 php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
574 fcd.fcz = getThis();
575 Z_ADDREF_P(fcd.fcz);
576 php_http_message_body_to_callback(obj->body, pass, &fcd, offset, forlen);
577 zval_ptr_dtor(&fcd.fcz);
578 RETURN_TRUE;
579 }
580 RETURN_FALSE;
581 }
582
583 PHP_METHOD(HttpMessageBody, append)
584 {
585 char *str;
586 int len;
587
588 if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &len)) {
589 php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
590
591 RETURN_LONG(php_http_message_body_append(obj->body, str, len));
592 }
593 RETURN_FALSE;
594 }
595
596 PHP_METHOD(HttpMessageBody, add)
597 {
598 HashTable *fields = NULL, *files = NULL;
599
600 if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|hh", &fields, &files)) {
601 php_http_message_body_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
602
603 RETURN_SUCCESS(php_http_message_body_add(obj->body, fields, files));
604 }
605 RETURN_FALSE;
606 }
607 /*
608 * Local variables:
609 * tab-width: 4
610 * c-basic-offset: 4
611 * End:
612 * vim600: noet sw=4 ts=4 fdm=marker
613 * vim<600: noet sw=4 ts=4
614 */