2003-06-11 23:36:48 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
2002-04-30 22:22:54 +00:00
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
2003-06-11 23:36:48 +00:00
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2003-10-16 19:03:49 +00:00
|
|
|
#include "cpp.h"
|
2002-07-22 23:07:14 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "winsock.h"
|
|
|
|
#include "win_net.h"
|
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
#include <stdio.h>
|
2002-07-22 23:07:14 +00:00
|
|
|
#if HAVE_UNISTD_H
|
2002-04-30 22:22:54 +00:00
|
|
|
#include <unistd.h>
|
2002-07-22 23:07:14 +00:00
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#include "http.h"
|
2002-06-10 06:14:18 +00:00
|
|
|
#include "log_flags.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "net_xfer.h"
|
2002-06-06 22:49:07 +00:00
|
|
|
#include "util.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
NET_XFER_SET nxs;
|
|
|
|
HTTP_OP_SET hos(&nxs);
|
2002-06-10 06:14:18 +00:00
|
|
|
HTTP_OP *op1=0, *op2=0, *op3=0;
|
2003-02-26 00:47:57 +00:00
|
|
|
int retval;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-07-22 23:07:14 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
NetOpen();
|
|
|
|
#endif
|
2002-06-10 06:14:18 +00:00
|
|
|
log_flags.http_debug = true;
|
|
|
|
log_flags.net_xfer_debug = true;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-10 06:14:18 +00:00
|
|
|
#if 0
|
|
|
|
op1 = new HTTP_OP;
|
2002-08-07 22:52:10 +00:00
|
|
|
retval = op1->init_get("http://localhost.localdomain/my_index.html", "test_out1", true);
|
2002-06-10 06:14:18 +00:00
|
|
|
if (retval) {
|
|
|
|
printf("init_post: %d\n", retval);
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
hos.insert(op1);
|
2002-06-10 06:14:18 +00:00
|
|
|
|
|
|
|
op2 = new HTTP_OP;
|
|
|
|
retval = op2->init_post("http://localhost.localdomain/test-cgi/cgi", "test_in1", "test_out2");
|
|
|
|
if (retval) {
|
|
|
|
printf("init_post: %d\n", retval);
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
hos.insert(op2);
|
2002-06-10 06:14:18 +00:00
|
|
|
#endif
|
|
|
|
op3 = new HTTP_OP;
|
|
|
|
retval = op3->init_head("http://localhost.localdomain/my_index2.html");
|
|
|
|
if (retval) {
|
|
|
|
printf("init_post: %d\n", retval);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
hos.insert(op3);
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
while (1) {
|
2003-02-26 00:47:57 +00:00
|
|
|
nxs.poll();
|
2002-04-30 22:22:54 +00:00
|
|
|
hos.poll();
|
|
|
|
if (op1 && op1->http_op_done()) {
|
|
|
|
printf("op1 done; status %d\n", op1->hrh.status);
|
|
|
|
hos.remove(op1);
|
|
|
|
op1 = 0;
|
|
|
|
}
|
|
|
|
if (op2 && op2->http_op_done()) {
|
|
|
|
printf("op2 done; status %d\n", op2->hrh.status);
|
|
|
|
hos.remove(op2);
|
|
|
|
op2 = 0;
|
|
|
|
}
|
2002-06-10 06:14:18 +00:00
|
|
|
if (op3 && op3->http_op_done()) {
|
|
|
|
printf("op3 done; status %d\n", op3->hrh.status);
|
|
|
|
hos.remove(op3);
|
|
|
|
op3 = 0;
|
|
|
|
}
|
|
|
|
if (!op1 && !op2 && !op3) break;
|
2003-03-11 22:18:01 +00:00
|
|
|
boinc_sleep(1.);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
printf("all done\n");
|
2002-07-22 23:07:14 +00:00
|
|
|
|
|
|
|
return 0;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|