LTP GCOV extension - code coverage report
Current view: directory - ext/http - http_request_info.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 68
Code covered: 100.0 % Executed lines: 68
Legend: not executed executed

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

Generated by: LTP GCOV extension version 1.5