17#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
24#ifndef GLOBUS_I_XIO_HTTP_H
25#define GLOBUS_I_XIO_HTTP_H 1
27#include "globus_xio.h"
28#include "globus_xio_driver.h"
31enum { GLOBUS_XIO_HTTP_CHUNK_SIZE = 4000 };
35 GLOBUS_XIO_HTTP_TRANSFER_ENCODING_DEFAULT,
36 GLOBUS_XIO_HTTP_TRANSFER_ENCODING_IDENTITY,
37 GLOBUS_XIO_HTTP_TRANSFER_ENCODING_CHUNKED
39globus_i_xio_http_transfer_encoding_t;
43 GLOBUS_XIO_HTTP_PRE_REQUEST_LINE,
44 GLOBUS_XIO_HTTP_REQUEST_LINE,
45 GLOBUS_XIO_HTTP_STATUS_LINE,
46 GLOBUS_XIO_HTTP_HEADERS,
47 GLOBUS_XIO_HTTP_CHUNK_CRLF,
48 GLOBUS_XIO_HTTP_CHUNK_LINE,
49 GLOBUS_XIO_HTTP_CHUNK_FOOTERS,
50 GLOBUS_XIO_HTTP_CHUNK_BODY,
51 GLOBUS_XIO_HTTP_IDENTITY_BODY,
55globus_i_xio_http_parse_state_t;
59 struct globus_i_xio_http_handle_s * http_handle;
60 globus_xio_operation_t user_read_op;
61 globus_xio_operation_t internal_op;
62 globus_xio_driver_handle_t driver_handle;
64globus_i_xio_http_cancellation_t;
66#define GLOBUS_XIO_HTTP_COPY_BLOB(fifo, blob, len, label) \
68 result = globus_i_xio_http_copy_blob(fifo, blob, len); \
69 if (result != GLOBUS_SUCCESS) \
80 globus_xio_iovec_t * iov;
88 globus_xio_operation_t operation;
92 globus_xio_driver_handle_t driver_handle;
105 globus_byte_t chunk_size_buffer[64];
107globus_i_xio_http_operation_info_t;
109#define GLOBUS_XIO_ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))
112#define GLOBUS_XIO_HTTP_TODO(msg) \
114 globus_libc_fprintf(stderr, "TODO: %s\n", msg); \
117#define GLOBUS_XIO_HTTP_TODO(msg) \
119 globus_libc_fprintf(stderr, "TODO: %s\n", msg); \
133 globus_bool_t is_client;
148globus_i_xio_http_target_t;
161 GLOBUS_I_XIO_HTTP_HEADER_ENTITY_NEEDED = 1 << 0,
165 GLOBUS_I_XIO_HTTP_HEADER_CONTENT_LENGTH_SET = 1 << 1,
169 GLOBUS_I_XIO_HTTP_HEADER_CONNECTION_CLOSE = 1 << 2
171globus_i_xio_http_header_flags_t;
175#define GLOBUS_I_XIO_HTTP_HEADER_IS_ENTITY_NEEDED(header) \
176 ((header)->flags & GLOBUS_I_XIO_HTTP_HEADER_ENTITY_NEEDED)
177#define GLOBUS_I_XIO_HTTP_HEADER_IS_CONTENT_LENGTH_SET(header) \
178 ((header)->flags & GLOBUS_I_XIO_HTTP_HEADER_CONTENT_LENGTH_SET)
179#define GLOBUS_I_XIO_HTTP_HEADER_IS_CONNECTION_CLOSE(header) \
180 ((header)->flags & GLOBUS_I_XIO_HTTP_HEADER_CONNECTION_CLOSE)
195 globus_hashtable_t headers;
199 globus_off_t content_length;
203 globus_i_xio_http_transfer_encoding_t
208 globus_i_xio_http_header_flags_t flags;
210globus_i_xio_http_header_info_t;
248 globus_i_xio_http_header_info_t headers;
250globus_i_xio_http_request_t;
272 char * reason_phrase;
284 globus_i_xio_http_header_info_t headers;
286globus_i_xio_http_response_t;
288typedef struct globus_i_xio_http_handle_s
293 globus_i_xio_http_target_t target_info;
297 globus_i_xio_http_request_t request_info;
302 globus_i_xio_http_response_t response_info;
306 globus_xio_driver_handle_t handle;
311 globus_xio_iovec_t * header_iovec;
320 globus_xio_iovec_t read_buffer;
326 globus_xio_iovec_t read_iovec;
331 globus_size_t read_buffer_offset;
337 globus_size_t read_buffer_valid;
342 globus_xio_operation_t close_operation;
347 globus_size_t read_chunk_left;
351 globus_bool_t delay_write_header;
355 const globus_xio_iovec_t * first_write_iovec;
359 int first_write_iovec_count;
363 globus_i_xio_http_parse_state_t parse_state;
367 globus_i_xio_http_parse_state_t send_state;
373 globus_xio_operation_t response_read_operation;
376 globus_i_xio_http_operation_info_t read_operation;
377 globus_i_xio_http_operation_info_t write_operation;
382 globus_bool_t user_close;
388 globus_bool_t read_response;
393 globus_mutex_t mutex;
398 globus_i_xio_http_cancellation_t * cancellation;
404 globus_bool_t reopen_in_progress;
409 globus_object_t * pending_error;
411globus_i_xio_http_handle_t;
421 globus_i_xio_http_request_t request;
422 globus_bool_t delay_write_header;
425 globus_i_xio_http_response_t response;
427globus_i_xio_http_attr_t;
432globus_i_xio_http_copy_blob(
433 globus_fifo_t * fifo,
439globus_i_xio_http_find_eol(
441 globus_size_t blob_length);
445globus_i_xio_http_method_requires_entity(
446 const char * method);
450globus_i_xio_http_guess_version(
456globus_i_xio_http_clean_read_buffer(
457 globus_i_xio_http_handle_t * http_handle);
462globus_i_xio_http_attr_init(
467globus_i_xio_http_attr_cntl(
474globus_i_xio_http_attr_copy(
480globus_i_xio_http_attr_destroy(
486globus_i_xio_http_client_write_request(
487 globus_xio_operation_t op,
488 globus_i_xio_http_handle_t * http_handle);
492globus_i_xio_http_client_open_callback(
493 globus_xio_operation_t op,
494 globus_result_t result,
500globus_i_xio_http_handle_init(
501 globus_i_xio_http_handle_t * http_handle,
502 globus_i_xio_http_attr_t * attr,
503 globus_i_xio_http_target_t * target);
507globus_i_xio_http_handle_reinit(
508 globus_i_xio_http_handle_t * http_handle,
509 globus_i_xio_http_attr_t * http_attr,
510 globus_i_xio_http_target_t * http_target);
514globus_i_xio_http_handle_destroy(
515 globus_i_xio_http_handle_t * http_handle);
519globus_i_xio_http_handle_cntl(
526globus_i_xio_http_set_end_of_entity(
527 globus_i_xio_http_handle_t * http_handle);
532globus_i_xio_http_header_copy(
540globus_i_xio_http_header_destroy(
545globus_i_xio_http_header_parse(
546 globus_i_xio_http_handle_t * handle,
547 globus_bool_t * done);
552globus_i_xio_http_header_info_init(
553 globus_i_xio_http_header_info_t * headers);
557globus_i_xio_http_header_info_destroy(
558 globus_i_xio_http_header_info_t * headers);
562globus_i_xio_http_header_info_copy(
563 globus_i_xio_http_header_info_t * dest,
564 const globus_i_xio_http_header_info_t *
568globus_i_xio_http_header_info_set_header(
569 globus_i_xio_http_header_info_t * headers,
570 const char * header_name,
571 const char * header_value,
572 globus_bool_t store_all);
577globus_i_xio_http_lookup_reason(
582globus_i_xio_http_target_t *
583globus_i_xio_http_target_new(
void);
587globus_i_xio_http_target_destroy(
588 void * driver_target);
592globus_i_xio_http_target_destroy_internal(
593 globus_i_xio_http_target_t * target);
598globus_i_xio_http_request_init(
599 globus_i_xio_http_request_t * request);
603globus_i_xio_http_request_copy(
604 globus_i_xio_http_request_t * dest,
605 const globus_i_xio_http_request_t * src);
609globus_i_xio_http_request_destroy(
610 globus_i_xio_http_request_t * request);
615globus_i_xio_http_response_init(
616 globus_i_xio_http_response_t * response);
620globus_i_xio_http_response_copy(
621 globus_i_xio_http_response_t * dest,
622 const globus_i_xio_http_response_t *src);
626globus_i_xio_http_response_destroy(
627 globus_i_xio_http_response_t * response);
633globus_i_xio_http_server_read_request_callback(
634 globus_xio_operation_t op,
635 globus_result_t result,
636 globus_size_t nbytes,
641globus_i_xio_http_accept(
642 void * driver_server,
643 globus_xio_operation_t accept_op);
647globus_i_xio_http_server_open_callback(
648 globus_xio_operation_t op,
649 globus_result_t result,
654globus_i_xio_http_server_write_response(
655 globus_i_xio_http_handle_t * http_handle,
656 const globus_xio_iovec_t * iovec,
658 globus_xio_operation_t op);
662globus_i_xio_http_server_read_next_request(
663 globus_i_xio_http_handle_t * http_handle);
668globus_i_xio_http_target_init(
669 globus_i_xio_http_target_t ** out_target,
670 const globus_xio_contact_t * contact_info);
674globus_i_xio_http_target_copy(
675 globus_i_xio_http_target_t * dest,
676 const globus_i_xio_http_target_t * src);
679extern globus_list_t * globus_i_xio_http_cached_handles;
680extern globus_mutex_t globus_i_xio_http_cached_handle_mutex;
681extern globus_list_t * globus_i_xio_http_cancellable_handles;
682extern globus_mutex_t globus_i_xio_http_cancel_mutex;
686globus_i_xio_http_open(
687 const globus_xio_contact_t * contact_info,
690 globus_xio_operation_t op);
694globus_i_xio_http_read(
696 const globus_xio_iovec_t * iovec,
698 globus_xio_operation_t op);
702globus_i_xio_http_write(
704 const globus_xio_iovec_t * iovec,
706 globus_xio_operation_t op);
711globus_l_xio_http_client_parse_response(
712 globus_i_xio_http_handle_t * http_handle,
713 globus_bool_t * done);
716globus_l_xio_http_client_read_response_callback(
717 globus_xio_operation_t op,
718 globus_result_t result,
719 globus_size_t nbytes,
724globus_i_xio_http_parse_residue(
725 globus_i_xio_http_handle_t * handle,
726 globus_bool_t * registered_again);
730globus_i_xio_http_write_chunk(
731 globus_i_xio_http_handle_t * http_handle,
732 const globus_xio_iovec_t * iovec,
734 globus_xio_operation_t op);
738globus_i_xio_http_write_callback(
739 globus_xio_operation_t op,
740 globus_result_t result,
741 globus_size_t nbytes,
746globus_i_xio_http_close(
749 globus_xio_operation_t op);
753globus_i_xio_http_close_internal(
754 globus_i_xio_http_handle_t * http_handle);
758globus_i_xio_http_close_callback(
759 globus_xio_operation_t operation,
760 globus_result_t result,
763GlobusXIODeclareModule(http);
764#define GLOBUS_XIO_HTTP_MODULE GlobusXIOMyModule(http)
766#define GlobusXIOHttpErrorObjParse(token, context) \
767 globus_error_construct_error( \
768 GLOBUS_XIO_HTTP_MODULE, \
770 GLOBUS_XIO_HTTP_ERROR_PARSE, \
774 "Error parsing %s token at %s", \
777#define GlobusXIOHttpErrorParse(token, context) \
779 GlobusXIOHttpErrorObjParse(token, context))
781#define GlobusXIOHttpErrorObjInvalidHeader(name, value) \
782 globus_error_construct_error( \
783 GLOBUS_XIO_HTTP_MODULE, \
785 GLOBUS_XIO_HTTP_ERROR_INVALID_HEADER, \
789 "Invalid %s header value %s", \
792#define GlobusXIOHttpErrorInvalidHeader(name, value) \
794 GlobusXIOHttpErrorObjInvalidHeader(name, value))
796#define GlobusXIOHttpErrorObjNoEntity() \
797 globus_error_construct_error( \
798 GLOBUS_XIO_HTTP_MODULE, \
800 GLOBUS_XIO_HTTP_ERROR_NO_ENTITY, \
804 "No entity to read or write")
806#define GlobusXIOHttpErrorNoEntity() \
808 GlobusXIOHttpErrorObjNoEntity())
810#define GlobusXIOHttpErrorObjEOF() \
811 globus_error_construct_error( \
812 GLOBUS_XIO_HTTP_MODULE, \
814 GLOBUS_XIO_HTTP_ERROR_EOF, \
820#define GlobusXIOHttpErrorEOF() \
822 GlobusXIOHttpErrorObjEOF())
824#define GlobusXIOHttpErrorPersistentConnectionDropped(cause) \
826 GlobusXIOHTTPErrorObjPersistentConnectionDropped(cause))
828#define GlobusXIOHTTPErrorObjPersistentConnectionDropped(cause) \
829 globus_error_construct_error( \
830 GLOBUS_XIO_HTTP_MODULE, \
832 GLOBUS_XIO_HTTP_ERROR_PERSISTENT_CONNECTION_DROPPED, \
836 "Persistent connection dropped")
Globus XIO HTTP Driver Header.
globus_xio_http_version_t
Definition globus_xio_http.h:232