File: http_test_common.h

package info (click to toggle)
globus-xio 6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 8,128 kB
  • sloc: ansic: 46,711; sh: 11,139; perl: 1,598; makefile: 289
file content (120 lines) | stat: -rw-r--r-- 3,908 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HTTP_TEST_COMMON_H
#define HTTP_TEST_COMMON_H

#include "globus_xio.h"
#include "globus_xio_http.h"

typedef void (*globus_xio_http_request_ready_callback_t)(
    void *                              user_arg,
    globus_result_t                     result,
    const char *                        method,
    const char *                        uri,
    globus_xio_http_version_t           http_version,
    globus_hashtable_t                  headers);

typedef struct
{
    globus_mutex_t                      mutex;
    globus_cond_t                       cond;

    int                                 outstanding_operation;

    globus_xio_server_t                 server;
    globus_xio_handle_t                 handle;

    char *                              contact;

    globus_bool_t                       shutdown;
    globus_bool_t                       shutdown_done;

    globus_xio_http_version_t           http_version;
    char *                              transfer_encoding;
    globus_size_t                       buffer_size_t;

    globus_xio_driver_t                 http_driver;
    globus_xio_driver_t                 tcp_driver;

    globus_hashtable_t                  uri_handlers;
}
http_test_server_t;


globus_result_t
http_test_server_init(
    http_test_server_t *                server,
    globus_xio_driver_t                 tcp_driver,
    globus_xio_driver_t                 http_driver,
    globus_xio_stack_t                  stack);

globus_result_t
http_test_server_register_handler(
    http_test_server_t *                server,
    const char *                        uri,
    globus_xio_http_request_ready_callback_t
                                        ready_callback,
    void *                              arg);

globus_result_t
http_test_server_run(
    http_test_server_t *                server);

globus_result_t
http_test_server_shutdown(
    http_test_server_t *                server);

void
http_test_server_destroy(
    http_test_server_t *                server);

globus_result_t
http_test_server_respond(
    http_test_server_t *                server,
    int                                 status_code,
    char *                              reason_phrase,
    globus_xio_http_header_t *          header_array,
    size_t                              header_array_len);

globus_result_t
http_test_server_close_handle(
    http_test_server_t *                test_server);

globus_result_t
http_test_client_request(
    globus_xio_handle_t *               new_handle,
    globus_xio_driver_t                 tcp_driver,
    globus_xio_driver_t                 http_driver,
    globus_xio_stack_t                  stack,
    const char *                        contact,
    const char *                        uri,
    const char *                        method,
    globus_xio_http_version_t           http_version,
    globus_xio_http_header_t *          header_array,
    size_t                              header_array_length);

int
http_test_initialize(
    globus_xio_driver_t *               tcp_driver,
    globus_xio_driver_t *               http_driver,
    globus_xio_stack_t *                stack);

globus_bool_t
http_is_eof(
    globus_result_t                     res);

#endif /* HTTP_TEST_COMMON_H */