11 class HTTPInput : public Input {
13 HTTPInput(const std::string &stream_id, const std::string &url);
15 // Serialization/deserialization.
16 HTTPInput(const InputProto &serialized);
17 virtual InputProto serialize() const;
19 virtual std::string get_url() const { return url; }
22 // Actually does the download.
23 virtual void do_work();
25 // Open a socket that connects to the given host and port. Does DNS resolving.
26 int lookup_and_connect(const std::string &host, const std::string &port);
28 // Parses a HTTP response. Returns false if it not a 200.
29 bool parse_response(const std::string &response);
31 // Stores the given data, looks for Metacube blocks (skipping data if needed),
32 // and calls process_block() for each one.
33 void process_data(char *ptr, size_t bytes);
35 // Drops <num_bytes> bytes from the head of <pending_data>,
36 // and outputs a warning.
37 void drop_pending_data(size_t num_bytes);
44 CLOSING_SOCKET, // Due to error.
48 std::string stream_id;
50 // The URL and its parsed components.
52 std::string host, port, path;
54 // The HTTP request, with headers and all.
55 // Only relevant for SENDING_REQUEST.
58 // How many bytes we've sent of the request so far.
59 // Only relevant for SENDING_REQUEST.
60 size_t request_bytes_sent;
62 // The HTTP response we've received so far. Only relevant for RECEIVING_HEADER.
65 // The HTTP respones headers we want to give clients for this input.
66 std::string http_header;
68 // Data we have received but not fully processed yet.
69 std::vector<char> pending_data;
71 // If <pending_data> starts with a Metacube header,
73 bool has_metacube_header;
75 // The socket we are downloading on (or -1).
79 #endif // !defined(_HTTPINPUT_H)