1 /*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | http://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Israel Ekpo <iekpo@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17 #include "php_solr.h"
18
19 /* Used to set the properties of the SolrResponse instance after a call to the server */
20
21 /* {{{ PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success) */
solr_set_response_object_properties(zend_class_entry * scope,zval * response_object,const solr_client_t * client,const solr_string_t * request_url,zend_bool success)22 PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success)
23 {
24 const solr_curl_t *handle = &(client->handle);
25
26 const solr_string_t *raw_request_headers = &(handle->request_header.buffer);
27 const solr_string_t *raw_request = &(handle->request_body_debug.buffer);
28 const solr_string_t *raw_response_headers = &(handle->response_header.buffer);
29 const solr_string_t *raw_response = &(handle->response_body.buffer);
30 const solr_string_t *response_writer = &(client->options.response_writer);
31
32 long int http_status = handle->response_header.response_code;
33
34 zend_update_property_long(scope, OBJ_FOR_PROP(response_object), "http_status", sizeof("http_status")-1, http_status);
35
36 zend_update_property_bool(scope, OBJ_FOR_PROP(response_object), "success", sizeof("success")-1, success);
37
38 if (response_writer->str)
39 {
40 zend_update_property_stringl(scope, OBJ_FOR_PROP(response_object), "response_writer", sizeof("response_writer")-1, (char *)response_writer->str, response_writer->len);
41 }
42
43 if (request_url->str)
44 {
45 zend_update_property_stringl(scope, OBJ_FOR_PROP(response_object), "http_request_url", sizeof("http_request_url")-1, (char *)request_url->str, request_url->len);
46 }
47
48 if (raw_request_headers->str)
49 {
50 zend_update_property_stringl(scope, OBJ_FOR_PROP(response_object), "http_raw_request_headers", sizeof("http_raw_request_headers")-1, (char *)raw_request_headers->str, raw_request_headers->len);
51 }
52
53 if (raw_request->str)
54 {
55 zend_update_property_stringl(scope, OBJ_FOR_PROP(response_object), "http_raw_request", sizeof("http_raw_request")-1, (char *)raw_request->str, raw_request->len);
56 }
57
58 if (raw_response_headers->str)
59 {
60 zend_update_property_stringl(scope, OBJ_FOR_PROP(response_object), "http_raw_response_headers", sizeof("http_raw_response_headers")-1, (char *)raw_response_headers->str, raw_response_headers->len);
61 }
62
63 if (raw_response->str)
64 {
65 zend_update_property_stringl(scope, OBJ_FOR_PROP(response_object), "http_raw_response", sizeof("http_raw_response")-1, (char *)raw_response->str, raw_response->len);
66 }
67 }
68 /* }}} */
69
70 /*
71 * Local variables:
72 * tab-width: 4
73 * c-basic-offset: 4
74 * indent-tabs-mode: t
75 * End:
76 * vim600: fdm=marker
77 * vim: noet sw=4 ts=4
78 */
79