2 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
11 #ifndef GLOBUS_L_GASS_TRANSFER_HTTP_H
12 #define GLOBUS_L_GASS_TRANSFER_HTTP_H
23 GLOBUS_L_DEFAULT_HTTP_PORT = 80,
24 GLOBUS_L_DEFAULT_HTTPS_PORT = 443,
25 GLOBUS_L_GASS_RESPONSE_LEN = 256
30 GLOBUS_L_LINE_MODE_UNKNOWN,
31 GLOBUS_L_LINE_MODE_CR,
32 GLOBUS_L_LINE_MODE_LF,
33 GLOBUS_L_LINE_MODE_CRLF
34 } globus_gass_transfer_http_line_mode_t;
41 const globus_gass_transfer_http_line_mode_t
42 globus_l_gass_transfer_http_line_mode =
43 #ifndef TARGET_ARCH_WIN32
44 GLOBUS_L_LINE_MODE_LF;
46 GLOBUS_L_LINE_MODE_CRLF;
52 #define GLOBUS_L_TEXT_BYTE(text) (text & 0x7f)
54 static globus_mutex_t globus_l_gass_transfer_http_mutex;
55 static globus_cond_t globus_l_gass_transfer_http_cond;
57 #define globus_l_gass_transfer_http_lock() \
58 globus_mutex_lock(&globus_l_gass_transfer_http_mutex) \
60 #define globus_l_gass_transfer_http_unlock() \
62 globus_mutex_unlock(&globus_l_gass_transfer_http_mutex)
63 #define globus_l_gass_transfer_http_wait() \
64 globus_cond_wait(&globus_l_gass_transfer_http_cond, \
65 &globus_l_gass_transfer_http_mutex)
66 #define globus_l_gass_transfer_http_signal() \
67 globus_cond_signal(&globus_l_gass_transfer_http_cond)
69 static char * globus_l_gass_transfer_http_subject_name;
74 #define CRLF "\015\012"
75 #define CR_STRING "\015"
76 #define LF_STRING "\012"
79 #define GLOBUS_GASS_HTTP_VERSION "Globus-GASS-HTTP/1.1.0"
81 #define GLOBUS_L_APPEND_URI "/globus-bins/GASSappend?"
83 #define GLOBUS_L_GET_COMMAND "GET %s HTTP/1.1" CRLF \
85 "Connection: close" CRLF \
86 "User-Agent: " GLOBUS_GASS_HTTP_VERSION CRLF
88 #define GLOBUS_L_PUT_COMMAND "PUT %s HTTP/1.1" CRLF \
90 "Connection: close" CRLF \
91 "User-Agent: " GLOBUS_GASS_HTTP_VERSION CRLF
93 #define GLOBUS_L_APPEND_COMMAND "POST " GLOBUS_L_APPEND_URI "%s " \
96 "Connection: close" CRLF \
97 "User-Agent: " GLOBUS_GASS_HTTP_VERSION CRLF
99 #define GLOBUS_L_REFER_RESPONSE "HTTP/1.1 302 Moved Temporarily" CRLF \
100 "Connection: close" CRLF \
101 "Server: " GLOBUS_GASS_HTTP_VERSION CRLF
103 #define GLOBUS_L_CONTINUE_RESPONSE "HTTP/1.1 100 Continue" CRLF
105 #define GLOBUS_L_GENERIC_RESPONSE "HTTP/1.%d %d %s" CRLF \
106 "Connection: close" CRLF \
107 "Server: " GLOBUS_GASS_HTTP_VERSION CRLF
108 #define GLOBUS_L_OK "Ok"
110 #define GLOBUS_L_DENIAL_RESPONSE "HTTP/1.1 %d %s" CRLF \
111 "Connection: close" CRLF \
112 "Server: " GLOBUS_GASS_HTTP_VERSION CRLF
114 #define GLOBUS_L_DEFAULT_DENIAL_MESSAGE "Internal Server Error"
116 #define GLOBUS_L_CONTENT_LENGTH_HEADER "Content-Length: %ld" CRLF
117 #define GLOBUS_L_CHUNKED_HEADER "Transfer-Encoding: chunked" CRLF
118 #define GLOBUS_L_BINARY_HEADER "Content-Type: " \
119 "application/octet-stream" CRLF
120 #define GLOBUS_L_TEXT_HEADER "Content-Type: text/plain" CRLF
121 #define GLOBUS_L_HTML_HEADER "Content-Type: text/html" CRLF
122 #define GLOBUS_L_HTML_REFERRAL_BODY_HEAD \
123 "<html><head><title>Document Moved</title></head><body>"
124 #define GLOBUS_L_HTML_REFERRAL_BODY_TAIL \
126 #define GLOBUS_L_HTML_DENIAL_BODY "<html><head><title>%d %s</title></head><body>" CRLF \
127 "<h1>%d %s</h1></body></html>" CRLF
128 #define GLOBUS_L_HTML_HREF "<a href=\"%s\">%s</a><br>"
129 #define GLOBUS_L_LOCATION_HEADER "Location: %s" CRLF
131 #define GLOBUS_L_DEFAULT_FAILURE_CODE 400
132 #define GLOBUS_L_DEFAULT_FAILURE_REASON "Bad Request"
135 #define GLOBUS_L_PROTOCOL_FAILURE_CODE 416
136 #define GLOBUS_L_PROTOCOL_FAILURE_REASON "Protocol Error"
138 #define GLOBUS_L_MALLOC_FAILURE_CODE 417
139 #define GLOBUS_L_MALLOC_FAILURE_REASON "Malloc Error"
147 GLOBUS_GASS_TRANSFER_HTTP_STATE_CONNECTING,
148 GLOBUS_GASS_TRANSFER_HTTP_STATE_REQUESTING,
149 GLOBUS_GASS_TRANSFER_HTTP_STATE_CLOSING,
150 GLOBUS_GASS_TRANSFER_HTTP_STATE_REFERRED,
151 GLOBUS_GASS_TRANSFER_HTTP_STATE_DENIED,
152 GLOBUS_GASS_TRANSFER_HTTP_STATE_RESPONDING,
154 GLOBUS_GASS_TRANSFER_HTTP_STATE_IDLE,
155 GLOBUS_GASS_TRANSFER_HTTP_STATE_DONE,
156 GLOBUS_GASS_TRANSFER_HTTP_STATE_PENDING
157 } globus_gass_transfer_http_state_t;
162 GLOBUS_GASS_TRANSFER_HTTP_LISTENER_STARTING,
163 GLOBUS_GASS_TRANSFER_HTTP_LISTENER_LISTENING,
164 GLOBUS_GASS_TRANSFER_HTTP_LISTENER_READY,
165 GLOBUS_GASS_TRANSFER_HTTP_LISTENER_ACCEPTING,
166 GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING1,
167 GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSING2,
168 GLOBUS_GASS_TRANSFER_HTTP_LISTENER_CLOSED
169 } globus_gass_transfer_listener_state_t;
172 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_SIZE,
173 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_EXT,
174 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_CR,
175 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_HEADER_LF,
176 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_BODY,
177 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_CR,
178 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_END_BODY_LF,
179 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_CHUNK_FOOTER,
180 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_LENGTH,
181 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_UNTIL_EOF,
182 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_EOF,
183 GLOBUS_GASS_TRANSFER_HTTP_RECV_STATE_ERROR
184 } globus_l_gass_transfer_http_recv_state_t;
195 globus_gass_transfer_listener_t listener;
196 globus_io_handle_t handle;
197 globus_url_scheme_t url_scheme;
199 globus_gass_transfer_listener_state_t state;
200 globus_bool_t destroy_called;
202 struct globus_gass_transfer_http_request_proto_s * request;
203 } globus_gass_transfer_http_listener_proto_t;
205 typedef struct globus_gass_transfer_http_request_proto_s
220 globus_io_handle_t handle;
223 volatile globus_bool_t oneshot_registered;
224 volatile globus_bool_t oneshot_active;
226 volatile globus_gass_transfer_http_state_t state;
230 globus_bool_t failure_occurred;
231 globus_bool_t destroy_called;
234 globus_url_t proxy_url;
235 globus_bool_t text_mode;
236 globus_size_t block_size;
250 globus_size_t length;
251 globus_size_t handled;
252 globus_bool_t chunked;
254 globus_bool_t last_data;
256 globus_bool_t client_side;
259 globus_size_t chunk_left;
260 globus_l_gass_transfer_http_recv_state_t recv_state;
261 globus_bool_t eof_read;
264 globus_byte_t * response_buffer;
265 globus_size_t response_buflen;
266 globus_size_t response_offset;
267 globus_size_t parsed_offset;
270 globus_bool_t parse_error;
276 globus_list_t * headers;
279 globus_gass_transfer_http_line_mode_t line_mode;
284 globus_byte_t * user_buffer;
285 globus_size_t user_buflen;
286 globus_size_t user_offset;
287 globus_size_t user_waitlen;
289 globus_gass_transfer_authorization_t authorization_mode;
290 char * authorized_subject;
291 char * connected_subject;
296 globus_bool_t proxy_connect;
297 globus_bool_t got_response;
298 globus_bool_t waiting_for_response;
299 } globus_gass_transfer_http_request_proto_t;
304 #if !defined(GLOBUS_GASS_TRANSFER_HTTP_PARSER_TEST)
307 globus_l_gass_transfer_http_send(
310 globus_byte_t * buffer,
311 globus_size_t buffer_length,
312 globus_bool_t last_data);
316 globus_l_gass_transfer_http_receive(
319 globus_byte_t * buffer,
320 globus_size_t buffer_length,
321 globus_size_t wait_for_length);
325 globus_l_gass_transfer_http_writev_callback(
327 globus_io_handle_t * handle,
328 globus_result_t result,
330 globus_size_t iovcnt,
331 globus_size_t nbytes);
335 globus_l_gass_transfer_http_write_callback(
337 globus_io_handle_t * handle,
338 globus_result_t result,
340 globus_size_t nbytes);
344 globus_l_gass_transfer_http_write_response(
346 globus_io_handle_t * handle,
347 globus_result_t result,
349 globus_size_t nbytes);
353 globus_l_gass_transfer_http_proto_destroy(
354 globus_gass_transfer_http_request_proto_t * proto);
358 globus_l_gass_transfer_http_read_callback(
360 globus_io_handle_t * handle,
361 globus_result_t result,
363 globus_size_t nbytes);
367 globus_l_gass_transfer_http_read_buffered_callback(
369 globus_io_handle_t * handle,
370 globus_result_t result,
372 globus_size_t nbytes);
376 globus_l_gass_transfer_http_callback_read_buffered_callback(
381 globus_l_gass_transfer_http_callback_ready_callback(
384 globus_l_gass_transfer_http_copy_text_buffer(
385 globus_byte_t * output,
386 globus_byte_t * input,
387 globus_gass_transfer_http_line_mode_t * line_mode,
388 globus_size_t input_max_to_copy,
389 globus_size_t output_max_to_copy,
390 globus_size_t * input_copied,
391 globus_size_t * output_copied);
395 globus_l_gass_transfer_http_fail(
401 globus_l_gass_transfer_http_close_callback(
403 globus_io_handle_t * handle,
404 globus_result_t result);
408 globus_l_gass_transfer_http_accept_callback(
410 globus_io_handle_t * handle,
411 globus_result_t result);
416 globus_l_gass_transfer_http_destroy(
422 globus_l_gass_transfer_http_new_request(
424 globus_gass_transfer_requestattr_t * attr);
428 globus_l_gass_transfer_http_new_requestattr(
433 globus_l_gass_transfer_http_new_listenerattr(
438 globus_l_gass_transfer_http_close_listener(
440 globus_gass_transfer_listener_t listener);
444 globus_l_gass_transfer_http_listen(
446 globus_gass_transfer_listener_t listener);
450 globus_l_gass_transfer_http_accept(
452 globus_gass_transfer_listener_t listener,
454 globus_gass_transfer_requestattr_t * attr);
458 globus_l_gass_transfer_http_authorization_callback(
460 globus_io_handle_t * handle,
461 globus_result_t result,
463 gss_ctx_id_t context_handle);
467 globus_l_gass_transfer_http_listener_destroy(
469 globus_gass_transfer_listener_t listener);
473 globus_l_gass_transfer_http_new_listener(
474 globus_gass_transfer_listener_t listener,
475 globus_gass_transfer_listenerattr_t * attr,
482 globus_l_gass_transfer_http_connect_callback(
484 globus_io_handle_t * handle,
485 globus_result_t result);
489 globus_l_gass_transfer_http_command_callback(
491 globus_io_handle_t * handle,
492 globus_result_t result,
494 globus_size_t nbytes);
498 globus_l_gass_transfer_http_response_callback(
500 globus_io_handle_t * handle,
501 globus_result_t result,
503 globus_size_t nbytes);
507 globus_l_gass_transfer_http_listener_proto_destroy(
508 globus_gass_transfer_http_listener_proto_t *
512 globus_l_gass_transfer_http_callback_listen_callback(
517 globus_l_gass_transfer_http_listen_callback(
519 globus_io_handle_t * handle,
520 globus_result_t result);
525 globus_l_gass_transfer_http_find_crlf(
526 globus_byte_t * bytes,
528 globus_size_t * crlf_offset);
532 globus_l_gass_transfer_http_parse_headers(
533 globus_gass_transfer_http_request_proto_t * proto);
537 globus_l_gass_transfer_http_parse_one_header(
538 globus_gass_transfer_http_request_proto_t * proto,
539 globus_bool_t * last_header);
543 globus_l_gass_transfer_http_parse_status_line(
544 globus_gass_transfer_http_request_proto_t * proto);
563 globus_l_gass_transfer_http_callback_send_callback(
568 globus_l_gass_transfer_http_request_callback(
570 globus_io_handle_t * handle,
571 globus_result_t result,
573 globus_size_t nbytes);
577 globus_l_gass_transfer_http_register_read(
578 globus_gass_transfer_http_request_proto_t * proto);
582 globus_l_gass_transfer_http_construct_request(
583 globus_gass_transfer_http_request_proto_t * proto);
587 globus_l_gass_transfer_http_handle_chunk(
588 globus_gass_transfer_http_request_proto_t * proto);
592 globus_l_gass_transfer_http_parse_response(
593 globus_gass_transfer_http_request_proto_t * proto);
597 globus_l_gass_transfer_http_parse_request(
598 globus_gass_transfer_http_request_proto_t * proto);
602 globus_l_gass_transfer_http_parse_request_line(
603 globus_gass_transfer_http_request_proto_t * proto);
607 globus_l_gass_transfer_http_extract_referral(
608 globus_gass_transfer_http_request_proto_t * proto,
610 globus_size_t * referral_count);
614 globus_l_gass_transfer_http_callback_denied(
619 globus_l_gass_transfer_http_close(
620 globus_gass_transfer_http_request_proto_t * proto);
624 globus_l_gass_transfer_http_register_close(
625 globus_gass_transfer_http_request_proto_t * proto);
629 globus_l_gass_transfer_http_listener_close(
630 globus_gass_transfer_http_listener_proto_t * proto);
globus_gass_transfer_request_type_t
Definition: globus_gass_transfer.h:129
void(* globus_gass_transfer_proto_accept_t)(globus_gass_transfer_listener_proto_t *proto, globus_gass_transfer_listener_t listener, globus_gass_transfer_request_t request, globus_gass_transfer_requestattr_t *attr)
Definition: globus_gass_transfer_proto.h:342
void(* globus_gass_transfer_proto_receive_t)(globus_gass_transfer_request_proto_t *proto, globus_gass_transfer_request_t request, globus_byte_t *bytes, globus_size_t bytes_length, globus_size_t wait_for_length)
Definition: globus_gass_transfer_proto.h:147
void(* globus_gass_transfer_proto_listener_t)(globus_gass_transfer_listener_proto_t *proto, globus_gass_transfer_listener_t listener)
Definition: globus_gass_transfer_proto.h:274
void(* globus_gass_transfer_proto_send_t)(globus_gass_transfer_request_proto_t *proto, globus_gass_transfer_request_t request, globus_byte_t *bytes, globus_size_t send_length, globus_bool_t last_data)
Definition: globus_gass_transfer_proto.h:107
Protocol module listener handling structure.
Definition: globus_gass_transfer_proto.h:416
void(* globus_gass_transfer_proto_func_t)(globus_gass_transfer_request_proto_t *proto, globus_gass_transfer_request_t request)
Definition: globus_gass_transfer_proto.h:174
Protocol module request handling structure.
Definition: globus_gass_transfer_proto.h:370