开发者

Is it possible to issue http methods like get,post manually without using browser?

I would like to know whether its possible to execute different http protocol methods like GET,POST,HEAD,etc manually without using browser either through command prompt or using any programming language?

If开发者_JAVA百科 yes, then how to do this?

Please enlighten !!!


Curl makes this pretty easy:

# get
curl http://www.google.com/

# head
curl -I http://www.google.com/

# post application/x-www-form-urlencoded
curl -d "parameter1=value1&parameter2=value2" http://stackoverflow.com

Look at the command-line docs for examples of how to do more advanced requests.


Telnet from command line in windows, all programming languages (almost) has their own API for this.


Almost every language has at least one mechanism for performing HTTP requests. From the command line you can use tools such as wget and cURL.


It's possible, using php's header() functions or using telnet and typing out the headers manually.


You can use wget or curl to do this automatically, and if you want to do this by hand, use telnet or netcat.

  1. Read RFC 2616 or Wikipedia.

  2. Connect to the server:

     $ telnet www.example.com 80
     Trying 192.0.32.10...
     Connected to www.example.com.
     Escape character is '^]'.
    
  3. Enter your request:

     GET / HTTP/1.1
     Host: www.example.com
     Connection: close
      
    

    (That’s two newlines at the end)

  4. Examine the response:

     HTTP/1.0 302 Found
     Location: http://www.iana.org/domains/example/
     Server: BigIP
     Connection: close
     Content-Length: 0
    

There are also countless libraries, such as Python’s httplib.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜