Telnet to google.com - Your client has issued a malformed or illegal request

I learn about HTTP protocol. I wanted to get the result of google query using telnet.

I did it like this:

telnet google.com 80
Trying 172.217.20.206...
Connected to google.com.
Escape character is '^]'.
GET /search?q=hello+world http/1.1
host: google.com

But the response is quite not what I want:

HTTP/1.0 400 Bad Request
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Content-Length: 1555
Date: Thu, 13 Apr 2017 21:48:39 GMT
<!DOCTYPE html>
<html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 400 (Bad Request)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style> <a href=// id=logo aria-label=Google></span></a> <p><b>400.</b> <ins>That’s an error.</ins> <p>Your client has issued a malformed or illegal request. <ins>That’s all we know.</ins>
Connection closed by foreign host.

What's so bad about my request?

2

2 Answers

What's so bad about my request?

You don't need the http/1.1

$ telnet google.com 80
Trying 216.58.198.174...
Connected to google.com.
Escape character is '^]'.
GET /search?q=hello+world
HTTP/1.0 302 Found
Location:
Cache-Control: private
Content-Type: text/html; charset=UTF-8
P3P: CP="This is not a P3P policy! See for more info."
Date: Thu, 13 Apr 2017 23:15:57 GMT
Server: gws
Content-Length: 285
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: NID=101=OFb36GmHOF7h2VCg_9pDdxY1vDrp5JYXjQOEIpjyIR1LJt228TZHgfC_pfNeFAQsBvR1REMMBXDkJoyuI45KYt1u3OrSvWQu7guevtsYF2RGJiTUqx9gZLcxbfXcNdn6; expires=Fri, 13-Oct-2017 23:15:57 GMT; path=/; domain=.google.com; HttpOnly
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="">here</A>.
</BODY></HTML>
Connection closed by foreign host.
$
2

The http/1.1 in your request has to be uppercase, i.e. HTTP/1.1.

See this Stack Overflow post.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like