[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] com =?UTF-8?Q?pecl/search=5Fengine/solr=3A=20CURL=20debuging=20mode=20wit?= =?UTF-8?Q?h=2
From:       Omar Shaban <omars () php ! net>
Date:       2015-09-26 3:06:02
Message-ID: php-mail-4fb61f907ab38f1cf20bf7d050625e812015413691 () git ! php ! net
[Download RAW message or body]

Commit:    f728ce797ecf09984dfe7b2b2052a9e6546ba373
Author:    Omar Shaban <omars@php.net>         Sat, 26 Sep 2015 05:04:09 +0200
Parents:   3e62ae01f85f03663bf60d2e80908e4523fb7f9f
Branches:  curl-debug

Link:       http://git.php.net/?p=pecl/search_engine/solr.git;a=commitdiff;h=f728ce797ecf09984dfe7b2b2052a9e6546ba373


Log:
CURL debuging mode with logging all requests to /tmp/solr_curl_request.log

Changed paths:
  M  solr_functions_client.c


Diff:
diff --git a/solr_functions_client.c b/solr_functions_client.c
index 11d22fa..be38cfe 100644
--- a/solr_functions_client.c
+++ b/solr_functions_client.c
@@ -316,6 +316,75 @@ int solr_curl_debug_callback(CURL *curl_handle, curl_infotype \
infotype, solr_cha  }
 /* }}} */
 
+static
+ void dump(const char *text,
+           FILE *stream, unsigned char *ptr, size_t size)
+ {
+   size_t i;
+   size_t c;
+   unsigned int width=0x10;
+
+
+  fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n",
+           text, (long)size, (long)size);
+
+
+  for(i=0; i<size; i+= width) {
+     for(c = 0; (c < width) && (i+c < size); c++) {
+         if ((ptr[i+c]>=0x20) && (ptr[i+c]<0x80)) {
+             fputc((ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.', stream);
+         } else {
+             fprintf(stream, "\n");
+         }
+     }
+   }
+ }
+
+
+static
+ int my_trace(CURL *handle, curl_infotype type,
+              char *data, size_t size,
+              void *userp)
+ {
+   const char *text;
+   (void)handle; /* prevent compiler warning */
+   FILE *fp;
+  fp = fopen("/tmp/solr_curl_request.log","a+");
+  switch (type) {
+   case CURLINFO_TEXT:
+     fprintf(fp, "== Info: %s", data);
+   default: /* in case a new one is introduced to shock us */
+     return 0;
+
+
+  case CURLINFO_HEADER_OUT:
+     text = "=> Send header";
+     break;
+   case CURLINFO_DATA_OUT:
+     text = "=> Send data";
+     break;
+   case CURLINFO_SSL_DATA_OUT:
+     text = "=> Send SSL data";
+     break;
+   case CURLINFO_HEADER_IN:
+     text = "<= Recv header";
+     break;
+   case CURLINFO_DATA_IN:
+     text = "<= Recv data";
+     break;
+   case CURLINFO_SSL_DATA_IN:
+     text = "<= Recv SSL data";
+     break;
+   }
+
+  fprintf(fp, "\n");
+  dump(text, fp, (unsigned char *)data, size);
+  fclose(fp);
+   return 0;
+
+ }
+
+
 /* {{{ PHP_SOLR_API int solr_make_request(solr_client_t *client, solr_request_type_t \
request_type TSRMLS_DC) */  PHP_SOLR_API int solr_make_request(solr_client_t *client, \
solr_request_type_t request_type TSRMLS_DC)  {
@@ -366,6 +435,9 @@ PHP_SOLR_API int solr_make_request(solr_client_t *client, \
solr_request_type_t re  curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, \
header_list);  curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, \
sch->request_body.buffer.len);  curl_easy_setopt(sch->curl_handle, \
CURLOPT_POSTFIELDS, sch->request_body.buffer.str); +
+			curl_easy_setopt(sch->curl_handle, CURLOPT_DEBUGFUNCTION, my_trace);
+			curl_easy_setopt(sch->curl_handle, CURLOPT_VERBOSE, 1L);
 		}
 		break;


--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic