Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
400 Bad Request
#1
I am working thru some literature in an effort to learn python on my own. My efforts were progressing favorably until recently when the subject turned to sockets. I have little knowledge in networking but I need help in this area to continue on. The simple listing that I have copied from the book that I am working through looks like this. Also here is the error message:

import socket

mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

mysock.connect(("www.netbsd.org", 80))

mysock.send(b"GET / HTTP/1.0\n\n")

res = mysock.recv(1024)

while res != b"":
    print(res)
    res = mysock.recv(1024)
---------------------------------------------------------------
b'HTTP/1.1 400 Bad Request\r\nDate: Thu, 14 Dec 2017 11:03:36 GMT\r\nServer: Apache/2.4.27 (Unix)\r\nContent-Length: 226\r\nConnection: close\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>400 Bad Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser sent a request that this server could not understand.<br />\n</p>\n</body></html>\n'
Reply


Messages In This Thread
400 Bad Request - by jimmyjam123 - Dec-14-2017, 11:45 AM
RE: 400 Bad Request - by buran - Dec-14-2017, 12:39 PM
RE: 400 Bad Request - by wavic - Dec-14-2017, 12:39 PM
RE: 400 Bad Request - by j.crater - Dec-14-2017, 12:41 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020