test/http_test_common.h

00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef HTTP_TEST_COMMON_H
00018 #define HTTP_TEST_COMMON_H
00019 
00020 #include "globus_xio.h"
00021 #include "globus_xio_http.h"
00022 
00023 typedef void (*globus_xio_http_request_ready_callback_t)(
00024     void *                              user_arg,
00025     globus_result_t                     result,
00026     const char *                        method,
00027     const char *                        uri,
00028     globus_xio_http_version_t           http_version,
00029     globus_hashtable_t                  headers);
00030 
00031 typedef struct
00032 {
00033     globus_mutex_t                      mutex;
00034     globus_cond_t                       cond;
00035 
00036     int                                 outstanding_operation;
00037 
00038     globus_xio_server_t                 server;
00039     globus_xio_handle_t                 handle;
00040 
00041     char *                              contact;
00042 
00043     globus_bool_t                       shutdown;
00044     globus_bool_t                       shutdown_done;
00045 
00046     globus_xio_http_version_t           http_version;
00047     char *                              transfer_encoding;
00048     globus_size_t                       buffer_size_t;
00049 
00050     globus_xio_driver_t                 http_driver;
00051     globus_xio_driver_t                 tcp_driver;
00052 
00053     globus_hashtable_t                  uri_handlers;
00054 }
00055 http_test_server_t;
00056 
00057 
00058 globus_result_t
00059 http_test_server_init(
00060     http_test_server_t *                server,
00061     globus_xio_driver_t                 tcp_driver,
00062     globus_xio_driver_t                 http_driver,
00063     globus_xio_stack_t                  stack);
00064 
00065 globus_result_t
00066 http_test_server_register_handler(
00067     http_test_server_t *                server,
00068     const char *                        uri,
00069     globus_xio_http_request_ready_callback_t
00070                                         ready_callback,
00071     void *                              arg);
00072 
00073 globus_result_t
00074 http_test_server_run(
00075     http_test_server_t *                server);
00076 
00077 globus_result_t
00078 http_test_server_shutdown(
00079     http_test_server_t *                server);
00080 
00081 void
00082 http_test_server_destroy(
00083     http_test_server_t *                server);
00084 
00085 globus_result_t
00086 http_test_server_respond(
00087     http_test_server_t *                server,
00088     int                                 status_code,
00089     char *                              reason_phrase,
00090     globus_xio_http_header_t *          header_array,
00091     size_t                              header_array_len);
00092 
00093 globus_result_t
00094 http_test_server_close_handle(
00095     http_test_server_t *                test_server);
00096 
00097 globus_result_t
00098 http_test_client_request(
00099     globus_xio_handle_t *               new_handle,
00100     globus_xio_driver_t                 tcp_driver,
00101     globus_xio_driver_t                 http_driver,
00102     globus_xio_stack_t                  stack,
00103     const char *                        contact,
00104     const char *                        uri,
00105     const char *                        method,
00106     globus_xio_http_version_t           http_version,
00107     globus_xio_http_header_t *          header_array,
00108     size_t                              header_array_length);
00109 
00110 int
00111 http_test_initialize(
00112     globus_xio_driver_t *               tcp_driver,
00113     globus_xio_driver_t *               http_driver,
00114     globus_xio_stack_t *                stack);
00115 
00116 globus_bool_t
00117 http_is_eof(
00118     globus_result_t                     res);
00119 
00120 #endif /* HTTP_TEST_COMMON_H */

Generated on 25 Nov 2015 for globus_xio by  doxygen 1.4.7