1
/* $Id: http_connector_hit.c,v 6.5 2001/01/11 16:42:45 lavr Exp $
1
/* $Id: http_connector_hit.c,v 6.13 2004/04/01 14:14:02 lavr Exp $
2
2
* ===========================================================================
4
4
* PUBLIC DOMAIN NOTICE
28
28
* File Description:
29
29
* Hit an arbitrary URL using HTTP-based CONNECTOR
31
* --------------------------------------------------------------------------
32
* $Log: http_connector_hit.c,v $
33
* Revision 6.5 2001/01/11 16:42:45 lavr
34
* Registry Get/Set methods got the 'user_data' argument, forgotten earlier
36
* Revision 6.4 2000/11/15 17:27:29 vakatov
37
* Fixed path to the test CGI application.
39
* Revision 6.3 2000/09/27 16:00:24 lavr
40
* Registry entries adjusted
42
* Revision 6.2 2000/05/30 23:24:40 vakatov
43
* Cosmetic fix for the C++ compilation
45
* Revision 6.1 2000/04/21 19:56:28 vakatov
48
* ==========================================================================
33
#include "../ncbi_ansi_ext.h"
56
34
#include <connect/ncbi_http_connector.h>
57
35
#include <connect/ncbi_util.h>
36
/* This header must go last */
37
#include "test_assert.h"
61
40
/* Holder for the cmd.-line arg values describing the URL to hit
94
#define X_GET_VALUE(x_name, x_value) \
95
if (strcmp(name, x_name) == 0) { \
96
strncpy(value, x_value, value_size); \
97
value[value_size - 1] = '\0'; \
73
#define X_GET_VALUE(x_name, x_value) \
74
if (strcmp(name, x_name) == 0) { \
75
strncpy0(value, x_value, value_size - 1); \
101
79
X_GET_VALUE(REG_CONN_HOST, s_Args.host);
154
132
"Usage: %s host port path [args] [inp_file] [user_header]\n"
155
"Example: %s ray.nlm.nih.gov 6224 "
133
"Example: %s yar.ncbi.nlm.nih.gov 6224 "
156
134
"/tools/vakatov/con_url.cgi 'arg1+arg2+arg3'\n",
157
135
argv[0], argv[0]);
158
136
fprintf(stderr, "Too few arguments.\n");
184
status = CONN_Write(conn, buffer, n_read, &n_written);
162
status = CONN_Write(conn, buffer, n_read,
163
&n_written, eIO_WritePersist);
185
164
if (status != eIO_Success) {
186
165
fprintf(stderr, "Error writing to URL (%s)",
187
166
IO_StatusStr(status));
169
assert(n_written == n_read);
194
174
/* Read reply from connection, write it to standard output */
195
175
fprintf(stdout, "\n\n----- [BEGIN] HTTP Content -----\n");
197
status = CONN_Read(conn, buffer, sizeof(buffer), &n_read, eIO_Plain);
177
status = CONN_Read(conn,buffer,sizeof(buffer),&n_read,eIO_ReadPlain);
198
178
if (status != eIO_Success)
200
* --------------------------------------------------------------------------
201
* $Log: http_connector_hit.c,v $
202
* Revision 6.13 2004/04/01 14:14:02 lavr
203
* Spell "occurred", "occurrence", and "occurring"
205
* Revision 6.12 2004/02/23 15:23:42 lavr
206
* New (last) parameter "how" added in CONN_Write() API call
208
* Revision 6.11 2003/04/15 14:06:09 lavr
209
* Changed ray.nlm.nih.gov -> ray.ncbi.nlm.nih.gov
211
* Revision 6.10 2002/11/22 15:09:40 lavr
212
* Replace all occurrences of "ray" with "yar"
214
* Revision 6.9 2002/10/28 15:47:12 lavr
215
* Use "ncbi_ansi_ext.h" privately and use strncpy0()
217
* Revision 6.8 2002/08/07 16:38:08 lavr
218
* EIO_ReadMethod enums changed accordingly; log moved to end
220
* Revision 6.7 2002/03/22 19:45:55 lavr
221
* Test_assert.h made last among the include files
223
* Revision 6.6 2002/01/16 21:23:14 vakatov
224
* Utilize header "test_assert.h" to switch on ASSERTs in the Release mode too
226
* Revision 6.5 2001/01/11 16:42:45 lavr
227
* Registry Get/Set methods got the 'user_data' argument, forgotten earlier
229
* Revision 6.4 2000/11/15 17:27:29 vakatov
230
* Fixed path to the test CGI application.
232
* Revision 6.3 2000/09/27 16:00:24 lavr
233
* Registry entries adjusted
235
* Revision 6.2 2000/05/30 23:24:40 vakatov
236
* Cosmetic fix for the C++ compilation
238
* Revision 6.1 2000/04/21 19:56:28 vakatov
241
* ==========================================================================