-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RServer test code in Python langauge added
- Loading branch information
1 parent
0897fce
commit ac7e002
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import socket | ||
|
||
def test(): | ||
s = socket.socket() | ||
server_address = ("127.0.0.1", 80) | ||
s.connect(server_address) | ||
print("Connected to the server") | ||
request = "GET /test HTTP/1.1\r\n\r\n" | ||
print("Sending request to server:\n", request) | ||
s.sendall(request.encode()) | ||
print("Request sent successfullly") | ||
print("Now read response from server") | ||
response = b""; | ||
while True: | ||
data = s.recv(1024) | ||
if data: | ||
response += data | ||
# if data==b"": break | ||
else: | ||
break | ||
print("Response received from server completely:\n", response.decode()) | ||
|
||
|
||
if __name__ == "__main__": | ||
test() |