171 |
int s; |
int s; |
172 |
char req[2*STRLEN]; |
char req[2*STRLEN]; |
173 |
char *auth= get_basic_authentication_header(); |
char *auth= get_basic_authentication_header(); |
174 |
|
ssl_connection * ssl= NULL; |
175 |
|
|
176 |
|
if ( Run.httpdssl ) { |
177 |
|
|
178 |
|
ssl = new_ssl_connection(); |
179 |
|
|
180 |
|
} |
181 |
|
|
182 |
s= create_socket(Run.bind_addr?Run.bind_addr:"localhost", |
s= create_socket(Run.bind_addr?Run.bind_addr:"localhost", |
183 |
Run.httpdport, SOCK_STREAM); |
Run.httpdport, SOCK_STREAM); |
190 |
else { |
else { |
191 |
snprintf(req, sizeof(req), |
snprintf(req, sizeof(req), |
192 |
"GET /%s?action=%s HTTP/1.0\r\n%s\r\n", p->name, action, auth); |
"GET /%s?action=%s HTTP/1.0\r\n%s\r\n", p->name, action, auth); |
193 |
sock_send(s, req, sizeof(req), 0); |
|
194 |
close_socket(s); |
if ( ssl != NULL ) { |
195 |
|
|
196 |
|
if (!embed_ssl_socket(ssl, s)) { |
197 |
|
|
198 |
|
fprintf(stdout, "Failed establish SSL communication to monit" |
199 |
|
" server\n"); |
200 |
|
|
201 |
|
return; |
202 |
|
} |
203 |
|
|
204 |
|
send_ssl_socket(ssl, req, sizeof(req)); |
205 |
|
|
206 |
|
close_ssl_socket(ssl); |
207 |
|
close_socket(s); |
208 |
|
|
209 |
|
} else { |
210 |
|
|
211 |
|
sock_send(s, req, sizeof(req), 0); |
212 |
|
close_socket(s); |
213 |
|
|
214 |
|
} |
215 |
free(auth); |
free(auth); |
216 |
} |
} |
217 |
|
|
218 |
|
if ( Run.httpdssl ) { |
219 |
|
|
220 |
|
delete_ssl_socket(ssl); |
221 |
|
|
222 |
|
} |
223 |
} |
} |
224 |
|
|
225 |
|
|