1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

1008: Moved post_fd to the struct connection.

This commit is contained in:
Witold Filipczyk 2008-05-12 11:24:00 +02:00 committed by Witold Filipczyk
parent a14cad36ba
commit a6184b3081
5 changed files with 17 additions and 19 deletions

View File

@ -303,7 +303,7 @@ init_connection(struct uri *uri, struct uri *proxied_uri, struct uri *referrer,
conn->cache_mode = cache_mode;
conn->content_encoding = ENCODING_NONE;
conn->stream_pipes[0] = conn->stream_pipes[1] = -1;
conn->stream_pipes[0] = conn->stream_pipes[1] = conn->post_fd = -1;
init_list(conn->downloads);
conn->est_length = -1;
conn->timer = TIMER_ID_UNDEF;
@ -494,6 +494,7 @@ done_connection(struct connection *conn)
done_progress(conn->progress);
if (conn->upload_progress)
done_progress(conn->upload_progress);
if (conn->post_fd != -1) close(conn->post_fd);
mem_free(conn);
check_queue_bugs();
}

View File

@ -54,6 +54,7 @@ struct connection {
int tries;
timer_id_T timer;
int stream_pipes[2];
int post_fd; /* used when POSTing files */
unsigned int running:1;
unsigned int unrestartable:1;

View File

@ -126,7 +126,7 @@ send_big_files(struct socket *socket)
}
}
if (n) add_bytes_to_string(&data, buffer, n);
if (finish) {
write_to_socket(socket, data.source, data.length, S_SENT,
close_pipe_and_read);
@ -135,7 +135,7 @@ send_big_files(struct socket *socket)
assert(end);
*end = '\0';
http->post_fd = open(big_file + 1, O_RDONLY);
conn->post_fd = open(big_file + 1, O_RDONLY);
*end = BIG_FILE_CHAR;
http->post_data = end + 1;
socket->state = SOCKET_END_ONCLOSE;
@ -149,17 +149,16 @@ static void
send_big_files2(struct socket *socket)
{
struct connection *conn = socket->conn;
struct http_connection_info *http = conn->info;
unsigned char buffer[BIG_READ];
int n = safe_read(http->post_fd, buffer, BIG_READ);
int n = safe_read(conn->post_fd, buffer, BIG_READ);
if (n > 0) {
socket->state = SOCKET_END_ONCLOSE;
write_to_socket(socket, buffer, n, S_TRANS,
send_big_files2);
} else {
close(http->post_fd);
http->post_fd = -1;
close(conn->post_fd);
conn->post_fd = -1;
send_big_files(socket);
}
}

View File

@ -472,11 +472,9 @@ http_end_request(struct connection *conn, enum connection_state state,
{
shutdown_connection_stream(conn);
if (conn->info) {
struct http_connection_info *http = conn->info;
if (http->post_fd != -1) {
close(http->post_fd);
http->post_fd = -1;
if (conn->post_fd != -1) {
close(conn->post_fd);
conn->post_fd = -1;
}
}
@ -534,7 +532,7 @@ init_http_connection_info(struct connection *conn, int major, int minor, int clo
http->sent_version.minor = minor;
http->close = close;
http->post_fd = -1;
conn->post_fd = -1;
/* The CGI code uses this too and blacklisting expects a host name. */
if (conn->proxied_uri->protocol != PROTOCOL_FILE)
@ -667,7 +665,7 @@ send_big_files(struct socket *socket)
assert(end);
*end = '\0';
http->post_fd = open(big_file + 1, O_RDONLY);
conn->post_fd = open(big_file + 1, O_RDONLY);
*end = BIG_FILE_CHAR;
http->post_data = end + 1;
socket->state = SOCKET_END_ONCLOSE;
@ -684,7 +682,7 @@ send_big_files2(struct socket *socket)
struct connection *conn = socket->conn;
struct http_connection_info *http = conn->info;
unsigned char buffer[BIG_READ];
int n = safe_read(http->post_fd, buffer, BIG_READ);
int n = safe_read(conn->post_fd, buffer, BIG_READ);
if (n > 0) {
socket->state = SOCKET_END_ONCLOSE;
@ -692,8 +690,8 @@ send_big_files2(struct socket *socket)
write_to_socket(socket, buffer, n, S_TRANS,
send_big_files2);
} else {
close(http->post_fd);
http->post_fd = -1;
close(conn->post_fd);
conn->post_fd = -1;
send_big_files(socket);
}
}
@ -1080,7 +1078,7 @@ http_send_header(struct socket *socket)
if (big_files) {
assert(!use_connect && post_data);
assert(http->post_fd == -1);
assert(conn->post_fd == -1);
http->post_data = post_data;
socket->state = SOCKET_END_ONCLOSE;
if (!conn->upload_progress)

View File

@ -30,7 +30,6 @@ struct http_connection_info {
size_t total_upload_length;
size_t uploaded;
unsigned char *post_data;
int post_fd;
};