1 /* Internal "finger" protocol implementation */
9 #include "cache/cache.h"
10 #include "intl/gettext/libintl.h"
11 #include "main/module.h"
12 #include "network/connection.h"
13 #include "network/socket.h"
14 #include "protocol/finger/finger.h"
15 #include "protocol/protocol.h"
16 #include "protocol/uri.h"
17 #include "util/memory.h"
18 #include "util/string.h"
20 struct module finger_protocol_module
= struct_module(
21 /* name: */ N_("Finger"),
24 /* submodules: */ NULL
,
31 finger_get_response(struct socket
*socket
, struct read_buffer
*rb
)
33 struct connection
*conn
= socket
->conn
;
34 struct cache_entry
*cached
= get_cache_entry(conn
->uri
);
38 abort_connection(conn
, connection_state(S_OUT_OF_MEM
));
41 conn
->cached
= cached
;
43 if (socket
->state
== SOCKET_CLOSED
) {
44 abort_connection(conn
, connection_state(S_OK
));
51 if (add_fragment(conn
->cached
, conn
->from
, rb
->data
, l
) == 1)
55 kill_buffer_data(rb
, l
);
56 read_from_socket(conn
->socket
, rb
, connection_state(S_TRANS
),
61 finger_send_request(struct socket
*socket
)
63 struct connection
*conn
= socket
->conn
;
66 if (!init_string(&req
)) return;
67 /* add_to_string(&req, &rl, "/W"); */
69 if (conn
->uri
->user
) {
70 add_char_to_string(&req
, ' ');
71 add_bytes_to_string(&req
, conn
->uri
->user
, conn
->uri
->userlen
);
73 add_crlf_to_string(&req
);
74 request_from_socket(socket
, req
.source
, req
.length
,
75 connection_state(S_SENT
),
76 SOCKET_END_ONCLOSE
, finger_get_response
);
81 finger_protocol_handler(struct connection
*conn
)
84 make_connection(conn
->socket
, conn
->uri
, finger_send_request
,
85 conn
->cache_mode
>= CACHE_MODE_FORCE_RELOAD
);