I'm stuck with socket1 exercise

I’m doing Python class and run into issue in Chapter 12. When doing the socket1 exercise I supposed to connect to data.pr4e.org using telnet. I can connect to telnet, I paste GET http://data.pr4e.org/romeo.txt HTTP/1.0 and get this response. I spent 2 days looking online what am I doing wrong but could not find anything other then turn off firewall. Tried to do on my other comp that doesn’t have any antivirus but get the same response. I will really appreciate any help. Thank you.
HTTP/1.1 400 Bad Request Date: Thu, 16 Jul 2020 23:19:10 GMT Server: Apache/2.4.18 (Ubuntu) Content-Length: 308 Connection: close Content-Type: text/html; charset=iso-8859-1 400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.

Apache/2.4.18 (Ubuntu) Server at do1.dr-chuck Port 80

Connection to host lost.

i just pased that chapter and i can understand your frustration, kindly post your code so it would be easier to help.

There is no code. Its a video, and I’m able to open telnet, get black screen, but when I paste what he tells to paste I get the 400 bad request, connection to host lost. There is a link to the video: https://www.youtube.com/watch?v=dWLdI143W-g
Thank you.

Change \n\n to \r\n\r\n for the cmd line and the code should work.
cmd = ‘GET http://data.pr4e.org/romeo.txt HTTP/1.0\r\n\r\n’.encode()

1 Like

I am going through the python tutorials and have encountered a similar issue as yours( connecting to data.pr4e.org). Are you using a mac (MacOs)? If so, you might need to install telnet. Below are the steps I took to resolve the issue:

a. install homebrew on mac first: type in the following command line in terminal

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
b. enter "brew install telnet" command line into the terminal