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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
/*
* Licensedo to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 AXIS2_HTTP_TRANSPORT_UTILS_H
#define AXIS2_HTTP_TRANSPORT_UTILS_H
#define AXIS2_MTOM_OUTPUT_BUFFER_SIZE 1024
/**
* @ingroup axis2_core_transport_http
* @{
*/
/**
* @file axis2_http_transport_utils.h
* @brief axis2 HTTP Transport Utility functions
* This file includes functions that handles soap and rest request
* that comes to the engine via HTTP protocol.
*/
#include <axis2_const.h>
#include <axis2_defines.h>
#include <axutil_env.h>
#include <axiom_stax_builder.h>
#include <axis2_msg_ctx.h>
#include <axis2_conf_ctx.h>
#include <axutil_hash.h>
#include <axiom_element.h>
#include <axutil_stream.h>
#include <axiom_soap_envelope.h>
#include <axutil_http_chunked_stream.h>
#include <axis2_http_out_transport_info.h>
#include <axutil_url.h>
#include <axiom_mtom_sending_callback.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum axis2_http_method_types
{
AXIS2_HTTP_METHOD_GET = 0,
AXIS2_HTTP_METHOD_POST,
AXIS2_HTTP_METHOD_HEAD,
AXIS2_HTTP_METHOD_PUT,
AXIS2_HTTP_METHOD_DELETE
}axis2_http_method_types_t;
typedef struct axis2_http_transport_in
{
/** HTTP Content type */
axis2_char_t *content_type;
/** HTTP Content length */
int content_length;
/** Input message context */
axis2_msg_ctx_t *msg_ctx;
/** soap action */
axis2_char_t *soap_action;
/** complete request uri */
axis2_char_t *request_uri;
/** Input stream */
axutil_stream_t *in_stream;
/** remote request ip corresponds to CGI header REMOTE_ADDR */
axis2_char_t *remote_ip;
/** server port */
axis2_char_t *svr_port;
/** HTTP transfer encoding header value */
axis2_char_t *transfer_encoding;
/** HTTP Accept header */
axis2_char_t *accept_header;
/** HTTP Accept language header */
axis2_char_t *accept_language_header;
/** HTTP accept charset header */
axis2_char_t *accept_charset_header;
/** H&TTP METHOD Should be one of AXIS2_HTTP_METHOD_GET | AXIS2_HTTP_METHOD_POST |"
AXIS2_HTTP_METHOD_HEAD | AXIS2_HTTP_METHOD_PUT | AXIS2_HTTP_METHOD_DELETE" */
int request_method;
/** out transport */
axis2_http_out_transport_info_t *out_transport_info;
/** this is for serving services html */
axis2_char_t *request_url_prefix;
}axis2_http_transport_in_t;
typedef struct axis2_http_transport_out
{
/** HTTP Status code string */
axis2_char_t *http_status_code_name;
/** HTTP Status code value */
int http_status_code;
/** Out message context */
axis2_msg_ctx_t *msg_ctx;
/** Response data */
void *response_data;
/** HTTP content type */
axis2_char_t *content_type;
/** Response data length */
int response_data_length;
/** content language */
axis2_char_t *content_language;
/** output headers list */
axutil_array_list_t *output_headers;
}axis2_http_transport_out_t;
/**
* size of the key stored in the session file
*/
#define AXIS2_TRANSPORT_SESSION_KEY_SIZE 64
/**
* size of the value stored in the session file
*/
#define AXIS2_TRANSPORT_SESSION_VALUE_SIZE 256
typedef struct axis2_session_file_record
{
axis2_char_t key[AXIS2_TRANSPORT_SESSION_KEY_SIZE];
axis2_char_t value[AXIS2_TRANSPORT_SESSION_VALUE_SIZE];
} axis2_session_file_record_t;
/**
* This will retrieve the session table, set by a service or a module and store it in a session
* file named with the unique session id, generated here in. Then it return the Set-Cookie http
* header with value containing session id and session expire time.
* @param env, environments
* @param msg_ctx
* @return cookie_header
*/
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_session(
const axutil_env_t *env,
axis2_msg_ctx_t *msg_ctx);
/**
* When the transport receive a Cookie header it calls this function. This will retrieve the
* stored session info from the file related to the id value of the cookie. It also check
* whether the session has timeout by comparing the session expire time contained in the cookie
* value with the expire time contained in the file. If session expired then it return nothing.
* If session is still valid it put the values in a hash table and set it into message context.
* @param env, environments
* @param id
* @param msg_ctx
*/
AXIS2_EXTERN void AXIS2_CALL
axis2_http_transport_utils_set_session(
const axutil_env_t *env,
axis2_msg_ctx_t *msg_ctx,
axis2_char_t *session_str);
/**
* After receiving Set-Cookie header in client side store it
* @param env, environments
* @param msg_ctx
* @param cookie
*/
AXIS2_EXTERN void AXIS2_CALL
axis2_http_transport_utils_store_cookie(
const axutil_env_t *env,
axis2_msg_ctx_t *msg_ctx,
axis2_char_t *cookie);
/**
* Read from cookie store before sending from client side
* @param env, environments
* @param msg_ctx
* @return cookie string
*/
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_read_from_cookie_store(
const axutil_env_t *env,
axis2_msg_ctx_t *msg_ctx);
/**
* Initialize the axis2_http_tranport_in_t. Before using this structure users should
* initialize it using this method.
* @param in a pointer to a axis2_http_tranport_in_t
* @param env, environments
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_transport_in_init(axis2_http_transport_in_t *in,
const axutil_env_t *env);
/**
* Uninitialize the axis2_http_tranport_in_t. Before using this structure users should
* initialize it using this method.
* @param in a pointer to a axis2_http_tranport_in_t
* @param env, environments
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_transport_in_uninit(axis2_http_transport_in_t *request,
const axutil_env_t *env);
/**
* Initialize the axis2_http_tranport_out_t. Before using this structure users should
* initialize it using this method.
* @param out a pointer to a axis2_http_tranport_out_t
* @param env, environments
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_transport_out_init(axis2_http_transport_out_t *out,
const axutil_env_t *env);
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_transport_out_uninit(axis2_http_transport_out_t *response,
const axutil_env_t *env);
/**
* This methods provides the HTTP request handling functionality using axis2 for server side
* HTTP modules.
* @param env, environments
* @param conf_ctx, Instance of axis2_conf_ctx_t
* @param request, populated instance of axis2_http_transport_in_t struct
* @param response, an instance of axis2_http_transport_out_t struct
* @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_process_request(
const axutil_env_t *env,
axis2_conf_ctx_t *conf_ctx,
axis2_http_transport_in_t *request,
axis2_http_transport_out_t *response);
/**
* This function handles the HTTP POST request that comes to the axis2 engine.
* The request can be either a SOAP request OR a REST request.
* @param env, axutil_env_t instance
* @param msg_ctx, Input message context. (an instance of axis2_msg_ctx_t struct.)
* @param in_stream, This is the input message content represented as an axutil_stream instance.
* A callback function will be used to read as required from the stream with in the engine.
* @param out_stream, This is the output stream. The outgoing message contents is represented as
* an instance of axutil_stream
* @param content_type, HTTP content type. This value should not be null.
* @param content_length, HTTP Content length value.
* @param soap_action_header, SOAPAction header value. This is only required in case of SOAP 1.1.
* For SOAP 1.2 , the action header will be within the ContentType header and
* this method is able to obtain the extract the action header value from content type.
* @param request_uri, This is the HTTP request uri. Should not be null.
* @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_process_http_post_request(
const axutil_env_t * env,
axis2_msg_ctx_t * msg_ctx,
axutil_stream_t * in_stream,
axutil_stream_t * out_stream,
const axis2_char_t * content_type,
const int content_length,
axutil_string_t * soap_action_header,
const axis2_char_t * request_uri);
/**
* This method handles the HTTP put request. Parameters are similar to that of post_request
* method.
* @param env, environment
* @param msg_ctx, in message context.
* @param in_stream, input stream
* @param out_stream, output stream.
* @param content_type, HTTP ContentType header value
* @param content_length, HTTP Content length value
* @param soap_action_header, SOAP Action header value
* @param request_uri, request uri
* @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_process_http_put_request(
const axutil_env_t * env,
axis2_msg_ctx_t * msg_ctx,
axutil_stream_t * in_stream,
axutil_stream_t * out_stream,
const axis2_char_t * content_type,
const int content_length,
axutil_string_t * soap_action_header,
const axis2_char_t * request_uri);
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_http_transport_utils_process_http_get_request(
const axutil_env_t * env,
axis2_msg_ctx_t * msg_ctx,
axutil_stream_t * in_stream,
axutil_stream_t * out_stream,
const axis2_char_t * content_type,
axutil_string_t * soap_action_header,
const axis2_char_t * request_uri,
axis2_conf_ctx_t * conf_ctx,
axutil_hash_t * request_params);
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_http_transport_utils_process_http_head_request(
const axutil_env_t * env,
axis2_msg_ctx_t * msg_ctx,
axutil_stream_t * in_stream,
axutil_stream_t * out_stream,
const axis2_char_t * content_type,
axutil_string_t * soap_action_header,
const axis2_char_t * request_uri,
axis2_conf_ctx_t * conf_ctx,
axutil_hash_t * request_params);
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_http_transport_utils_process_http_delete_request(
const axutil_env_t * env,
axis2_msg_ctx_t * msg_ctx,
axutil_stream_t * in_stream,
axutil_stream_t * out_stream,
const axis2_char_t * content_type,
axutil_string_t * soap_action_header,
const axis2_char_t * request_uri,
axis2_conf_ctx_t * conf_ctx,
axutil_hash_t * request_params);
AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL
axis2_http_transport_utils_select_builder_for_mime(
const axutil_env_t * env,
axis2_char_t * request_uri,
axis2_msg_ctx_t * msg_ctx,
axutil_stream_t * in_stream,
axis2_char_t * content_type);
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_http_transport_utils_do_write_mtom(
const axutil_env_t * env,
axis2_msg_ctx_t * msg_ctx);
AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
axis2_http_transport_utils_get_request_params(
const axutil_env_t * env,
axis2_char_t * request_uri);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_not_found(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_not_implemented(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_method_not_allowed(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_not_acceptable(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_bad_request(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_request_timeout(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_conflict(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_gone(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_precondition_failed(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_request_entity_too_large(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_service_unavailable(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_internal_server_error(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_services_html(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_services_static_wsdl(
const axutil_env_t * env,
axis2_conf_ctx_t * conf_ctx,
axis2_char_t * request_url);
AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
axis2_http_transport_utils_get_request_params(
const axutil_env_t * env,
axis2_char_t * request_uri);
AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL
axis2_http_transport_utils_create_soap_msg(
const axutil_env_t * env,
axis2_msg_ctx_t * msg_ctx,
const axis2_char_t * soap_ns_uri);
AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
axis2_http_transport_utils_process_accept_headers(
const axutil_env_t *env,
axis2_char_t *accept_value);
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_transport_utils_send_mtom_message(
axutil_http_chunked_stream_t * chunked_stream,
const axutil_env_t * env,
axutil_array_list_t *mime_parts,
axis2_char_t *sending_callback_name);
AXIS2_EXTERN void AXIS2_CALL
axis2_http_transport_utils_destroy_mime_parts(
axutil_array_list_t *mime_parts,
const axutil_env_t *env);
AXIS2_EXTERN void *AXIS2_CALL
axis2_http_transport_utils_initiate_callback(
const axutil_env_t *env,
axis2_char_t *callback_name,
void *user_param,
axiom_mtom_sending_callback_t **callback);
AXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_http_transport_utils_is_callback_required(
const axutil_env_t *env,
axutil_array_list_t *mime_parts);
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axis2_http_transport_utils_get_session_id_from_cookie(
const axutil_env_t *env,
axis2_char_t *cookie);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* AXIS2_HTTP_TRANSPORT_UTILS_H */
|