webget done

This commit is contained in:
ridethepig 2023-02-17 15:44:38 +00:00
parent 6478b11352
commit 6dd84564cf

View File

@ -1,4 +1,5 @@
#include "socket.hh"
// #include "socket.hh"
#include "tcp_sponge_socket.hh"
#include "util.hh"
#include <cstdlib>
@ -16,7 +17,7 @@ void get_URL(const string &host, const string &path) {
// Then you'll need to print out everything the server sends back,
// (not just one call to read() -- everything) until you reach
// the "eof" (end of file).
TCPSocket sock;
CS144TCPSocket sock;
sock.connect(Address(host, "http"));
string request = "GET " + path + " HTTP/1.1\r\nHost: " + host + "\r\nConnection: close\r\n\r\n";
sock.write(request);
@ -25,6 +26,7 @@ void get_URL(const string &host, const string &path) {
cout << recvd;
recvd = sock.read();
}
sock.wait_until_closed();
// cerr << "Function called: get_URL(" << host << ", " << path << ").\n";
// cerr << "Warning: get_URL() has not been implemented yet.\n";
}