- a service implemented with libxmlrpc-c3 chokes on a request content type
[m6w6/ext-http] / http_request_info.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-2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id$ */
14
15 #define HTTP_WANT_CURL
16 #include "php_http.h"
17
18 #include "php_http_request_api.h"
19
20 /* {{{ void http_request_info(http_request *, HashTable *) */
21 PHP_HTTP_API void _http_request_info(http_request *request, HashTable *info)
22 {
23 char *c;
24 long l;
25 double d;
26 struct curl_slist *s, *p;
27 zval *subarray, array;
28 INIT_ZARR(array, info);
29
30 /* BEGIN */
31 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_EFFECTIVE_URL, &c)) {
32 add_assoc_string_ex(&array, "effective_url", sizeof("effective_url"), c ? c : "", 1);
33 }
34 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_RESPONSE_CODE, &l)) {
35 add_assoc_long_ex(&array, "response_code", sizeof("response_code"), l);
36 }
37 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_TOTAL_TIME, &d)) {
38 add_assoc_double_ex(&array, "total_time", sizeof("total_time"), d);
39 }
40 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_NAMELOOKUP_TIME, &d)) {
41 add_assoc_double_ex(&array, "namelookup_time", sizeof("namelookup_time"), d);
42 }
43 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_CONNECT_TIME, &d)) {
44 add_assoc_double_ex(&array, "connect_time", sizeof("connect_time"), d);
45 }
46 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_PRETRANSFER_TIME, &d)) {
47 add_assoc_double_ex(&array, "pretransfer_time", sizeof("pretransfer_time"), d);
48 }
49 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_SIZE_UPLOAD, &d)) {
50 add_assoc_double_ex(&array, "size_upload", sizeof("size_upload"), d);
51 }
52 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_SIZE_DOWNLOAD, &d)) {
53 add_assoc_double_ex(&array, "size_download", sizeof("size_download"), d);
54 }
55 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_SPEED_DOWNLOAD, &d)) {
56 add_assoc_double_ex(&array, "speed_download", sizeof("speed_download"), d);
57 }
58 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_SPEED_UPLOAD, &d)) {
59 add_assoc_double_ex(&array, "speed_upload", sizeof("speed_upload"), d);
60 }
61 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_HEADER_SIZE, &l)) {
62 add_assoc_long_ex(&array, "header_size", sizeof("header_size"), l);
63 }
64 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_REQUEST_SIZE, &l)) {
65 add_assoc_long_ex(&array, "request_size", sizeof("request_size"), l);
66 }
67 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_SSL_VERIFYRESULT, &l)) {
68 add_assoc_long_ex(&array, "ssl_verifyresult", sizeof("ssl_verifyresult"), l);
69 }
70 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_FILETIME, &l)) {
71 add_assoc_long_ex(&array, "filetime", sizeof("filetime"), l);
72 }
73 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
74 add_assoc_double_ex(&array, "content_length_download", sizeof("content_length_download"), d);
75 }
76 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_CONTENT_LENGTH_UPLOAD, &d)) {
77 add_assoc_double_ex(&array, "content_length_upload", sizeof("content_length_upload"), d);
78 }
79 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_STARTTRANSFER_TIME, &d)) {
80 add_assoc_double_ex(&array, "starttransfer_time", sizeof("starttransfer_time"), d);
81 }
82 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_CONTENT_TYPE, &c)) {
83 add_assoc_string_ex(&array, "content_type", sizeof("content_type"), c ? c : "", 1);
84 }
85 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_REDIRECT_TIME, &d)) {
86 add_assoc_double_ex(&array, "redirect_time", sizeof("redirect_time"), d);
87 }
88 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_REDIRECT_COUNT, &l)) {
89 add_assoc_long_ex(&array, "redirect_count", sizeof("redirect_count"), l);
90 }
91 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_HTTP_CONNECTCODE, &l)) {
92 add_assoc_long_ex(&array, "connect_code", sizeof("connect_code"), l);
93 }
94 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_HTTPAUTH_AVAIL, &l)) {
95 add_assoc_long_ex(&array, "httpauth_avail", sizeof("httpauth_avail"), l);
96 }
97 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_PROXYAUTH_AVAIL, &l)) {
98 add_assoc_long_ex(&array, "proxyauth_avail", sizeof("proxyauth_avail"), l);
99 }
100 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_OS_ERRNO, &l)) {
101 add_assoc_long_ex(&array, "os_errno", sizeof("os_errno"), l);
102 }
103 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_NUM_CONNECTS, &l)) {
104 add_assoc_long_ex(&array, "num_connects", sizeof("num_connects"), l);
105 }
106 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_SSL_ENGINES, &s)) {
107 MAKE_STD_ZVAL(subarray);
108 array_init(subarray);
109 for (p = s; p; p = p->next) {
110 add_next_index_string(subarray, p->data, 1);
111 }
112 add_assoc_zval_ex(&array, "ssl_engines", sizeof("ssl_engines"), subarray);
113 curl_slist_free_all(s);
114 }
115 #if HTTP_CURL_VERSION(7,14,1)
116 if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_COOKIELIST, &s)) {
117 MAKE_STD_ZVAL(subarray);
118 array_init(subarray);
119 for (p = s; p; p = p->next) {
120 add_next_index_string(subarray, p->data, 1);
121 }
122 add_assoc_zval_ex(&array, "cookies", sizeof("cookies"), subarray);
123 curl_slist_free_all(s);
124 }
125 #endif
126 /* END */
127 add_assoc_string_ex(&array, "error", sizeof("error"), request->_error, 1);
128 }
129 /* }}} */
130
131 /*
132 * Local variables:
133 * tab-width: 4
134 * c-basic-offset: 4
135 * End:
136 * vim600: noet sw=4 ts=4 fdm=marker
137 * vim<600: noet sw=4 ts=4
138 */