webget done
This commit is contained in:
parent
6478b11352
commit
6dd84564cf
@ -1,4 +1,5 @@
|
|||||||
#include "socket.hh"
|
// #include "socket.hh"
|
||||||
|
#include "tcp_sponge_socket.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
#include <cstdlib>
|
#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,
|
// Then you'll need to print out everything the server sends back,
|
||||||
// (not just one call to read() -- everything) until you reach
|
// (not just one call to read() -- everything) until you reach
|
||||||
// the "eof" (end of file).
|
// the "eof" (end of file).
|
||||||
TCPSocket sock;
|
CS144TCPSocket sock;
|
||||||
sock.connect(Address(host, "http"));
|
sock.connect(Address(host, "http"));
|
||||||
string request = "GET " + path + " HTTP/1.1\r\nHost: " + host + "\r\nConnection: close\r\n\r\n";
|
string request = "GET " + path + " HTTP/1.1\r\nHost: " + host + "\r\nConnection: close\r\n\r\n";
|
||||||
sock.write(request);
|
sock.write(request);
|
||||||
@ -25,6 +26,7 @@ void get_URL(const string &host, const string &path) {
|
|||||||
cout << recvd;
|
cout << recvd;
|
||||||
recvd = sock.read();
|
recvd = sock.read();
|
||||||
}
|
}
|
||||||
|
sock.wait_until_closed();
|
||||||
// cerr << "Function called: get_URL(" << host << ", " << path << ").\n";
|
// cerr << "Function called: get_URL(" << host << ", " << path << ").\n";
|
||||||
// cerr << "Warning: get_URL() has not been implemented yet.\n";
|
// cerr << "Warning: get_URL() has not been implemented yet.\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user