Ricky Wilson
Ricky Wilson

Reputation: 3359

How do i format an HTTP request

This works just fine.

sock.send("GET / HTTP/1.0%s" % (CRLF))

When I use this one google replies by telling me the client sent a malformed request.

 sock.send("GET {0} HTTP/ {1}".format(path, CRLF))

Upvotes: 0

Views: 39

Answers (1)

Erty Seidohl
Erty Seidohl

Reputation: 4549

You're missing the HTTP version in the second:

"GET {0} HTTP/ {1}"

should be

"GET {0} HTTP/1.0 {1}"

You also may need to remove the trailing space.

Upvotes: 1

Related Questions