summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index d0871c4..153e492 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -239,10 +239,10 @@ void print_help (void);
239void print_usage (void); 239void print_usage (void);
240void print_curl_version (void); 240void print_curl_version (void);
241int curlhelp_initwritebuffer (curlhelp_write_curlbuf*); 241int curlhelp_initwritebuffer (curlhelp_write_curlbuf*);
242int curlhelp_buffer_write_callback (void*, size_t , size_t , void*); 242size_t curlhelp_buffer_write_callback(void*, size_t , size_t , void*);
243void curlhelp_freewritebuffer (curlhelp_write_curlbuf*); 243void curlhelp_freewritebuffer (curlhelp_write_curlbuf*);
244int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t); 244int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t);
245int curlhelp_buffer_read_callback (void *, size_t , size_t , void *); 245size_t curlhelp_buffer_read_callback(void *, size_t , size_t , void *);
246void curlhelp_freereadbuffer (curlhelp_read_curlbuf *); 246void curlhelp_freereadbuffer (curlhelp_read_curlbuf *);
247curlhelp_ssl_library curlhelp_get_ssl_library (); 247curlhelp_ssl_library curlhelp_get_ssl_library ();
248const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library); 248const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library);
@@ -485,7 +485,7 @@ check_http (void)
485 485
486 /* register cleanup function to shut down libcurl properly */ 486 /* register cleanup function to shut down libcurl properly */
487 atexit (cleanup); 487 atexit (cleanup);
488 488
489 if (verbose >= 1) 489 if (verbose >= 1)
490 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_VERBOSE, 1), "CURLOPT_VERBOSE"); 490 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_VERBOSE, 1), "CURLOPT_VERBOSE");
491 491
@@ -805,7 +805,7 @@ check_http (void)
805 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_INFILESIZE, (curl_off_t)strlen (http_post_data)), "CURLOPT_INFILESIZE"); 805 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_INFILESIZE, (curl_off_t)strlen (http_post_data)), "CURLOPT_INFILESIZE");
806 } 806 }
807 } 807 }
808 808
809 /* cookie handling */ 809 /* cookie handling */
810 if (cookie_jar_file != NULL) { 810 if (cookie_jar_file != NULL) {
811 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR"); 811 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR");
@@ -1167,7 +1167,7 @@ GOT_FIRST_CERT:
1167 else 1167 else
1168 msg[strlen(msg)-3] = '\0'; 1168 msg[strlen(msg)-3] = '\0';
1169 } 1169 }
1170 1170
1171 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ 1171 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
1172 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s", 1172 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
1173 state_text(result), string_statuscode (status_line.http_major, status_line.http_minor), 1173 state_text(result), string_statuscode (status_line.http_major, status_line.http_minor),
@@ -1218,6 +1218,10 @@ redir (curlhelp_write_curlbuf* header_buf)
1218 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen, 1218 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
1219 headers, &nof_headers, 0); 1219 headers, &nof_headers, 0);
1220 1220
1221 if (res == -1) {
1222 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Failed to parse Response\n"));
1223 }
1224
1221 location = get_header_value (headers, nof_headers, "location"); 1225 location = get_header_value (headers, nof_headers, "location");
1222 1226
1223 if (verbose >= 2) 1227 if (verbose >= 2)
@@ -1694,7 +1698,7 @@ process_arguments (int argc, char **argv)
1694 else { 1698 else {
1695 max_depth = atoi (optarg); 1699 max_depth = atoi (optarg);
1696 } 1700 }
1697 break; 1701 break;
1698 case 'f': /* onredirect */ 1702 case 'f': /* onredirect */
1699 if (!strcmp (optarg, "ok")) 1703 if (!strcmp (optarg, "ok"))
1700 onredirect = STATE_OK; 1704 onredirect = STATE_OK;
@@ -2171,8 +2175,7 @@ curlhelp_initwritebuffer (curlhelp_write_curlbuf *buf)
2171 return 0; 2175 return 0;
2172} 2176}
2173 2177
2174int 2178size_t curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *stream)
2175curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *stream)
2176{ 2179{
2177 curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream; 2180 curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream;
2178 2181
@@ -2192,8 +2195,7 @@ curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *s
2192 return (int)(size * nmemb); 2195 return (int)(size * nmemb);
2193} 2196}
2194 2197
2195int 2198size_t curlhelp_buffer_read_callback(void *buffer, size_t size, size_t nmemb, void *stream)
2196curlhelp_buffer_read_callback (void *buffer, size_t size, size_t nmemb, void *stream)
2197{ 2199{
2198 curlhelp_read_curlbuf *buf = (curlhelp_read_curlbuf *)stream; 2200 curlhelp_read_curlbuf *buf = (curlhelp_read_curlbuf *)stream;
2199 2201
@@ -2390,6 +2392,10 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA
2390 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen, 2392 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
2391 headers, &nof_headers, 0); 2393 headers, &nof_headers, 0);
2392 2394
2395 if (res == -1) {
2396 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Failed to parse Response\n"));
2397 }
2398
2393 server_date = get_header_value (headers, nof_headers, "date"); 2399 server_date = get_header_value (headers, nof_headers, "date");
2394 document_date = get_header_value (headers, nof_headers, "last-modified"); 2400 document_date = get_header_value (headers, nof_headers, "last-modified");
2395 2401
@@ -2465,9 +2471,7 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA
2465int 2471int
2466get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf) 2472get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf)
2467{ 2473{
2468 const char *s;
2469 int content_length = 0; 2474 int content_length = 0;
2470 char *copy;
2471 struct phr_header headers[255]; 2475 struct phr_header headers[255];
2472 size_t nof_headers = 255; 2476 size_t nof_headers = 255;
2473 size_t msglen; 2477 size_t msglen;
@@ -2478,6 +2482,10 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri
2478 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen, 2482 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
2479 headers, &nof_headers, 0); 2483 headers, &nof_headers, 0);
2480 2484
2485 if (res == -1) {
2486 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Failed to parse Response\n"));
2487 }
2488
2481 content_length_s = get_header_value (headers, nof_headers, "content-length"); 2489 content_length_s = get_header_value (headers, nof_headers, "content-length");
2482 if (!content_length_s) { 2490 if (!content_length_s) {
2483 return header_buf->buflen + body_buf->buflen; 2491 return header_buf->buflen + body_buf->buflen;