zoukankan      html  css  js  c++  java
  • http协议内容展示以及如何用telnet发送请求

    1.http协议组成:

      报文首部:状态行(请求行) 请求首部字段 通用字段 其他信息

      空行

      报文主体

    GET请求头:
    GET /test.php?a=1 HTTP/1.1
    Host: localhost
    Connection: keep-alive
    Cache-Control: max-age=0
    Upgrade-Insecure-Requests: 1
    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Accept-Encoding: gzip, deflate, sdch, br
    Accept-Language: zh-CN,zh;q=0.8
    POST请求头:
    POST /test.php HTTP/1.1
    Host: localhost
    Connection: keep-alive
    Content-Length: 42
    Cache-Control: max-age=0
    Origin: http://localhost
    Upgrade-Insecure-Requests: 1
    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
    Content-Type: application/x-www-form-urlencoded
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Referer: http://localhost/test.php
    Accept-Encoding: gzip, deflate, br
    Accept-Language: zh-CN,zh;q=0.8

    2.在命令行下用telnet模拟发送get或post请求

      1.cmd
      2.telnet localhost 80
      3.先同时按下"ctrl + ]" 用于回显内容,再按下"回车键"
      4.黏贴请求头
      
    GET请求头:
    GET /test.php?a=1 HTTP/1.1
    HOST:localhost
    
    POST请求头:
    POST /test.php HTTP/1.1
    HOST:localhost
    Content-Length:7 // 必须加上这个头
    Content-type:application/x-www-form-urlencoded
    
    name=ht // 在上面的请求头黏贴完毕后,回车两次,再输入

    // get请求头黏贴后,回车两次,显示请求内容;post请求头,黏贴完毕后,回车,输入post请求参数字符串,自动显示请求内容
      
                        
  • 相关阅读:
    log4net详细配置说明
    step by step 之餐饮管理系统三
    CF div2 331 C
    CF div2 331 B
    CF div2 331 A
    poj 2065 还是gauss消元
    poj 3478 poj 3090(欧拉函数的应用)
    poj 1284 求原根的个数(欧拉函数的应用)
    poj 2991 线段树
    poj 1753 poj3185
  • 原文地址:https://www.cnblogs.com/taotaoxixihaha/p/6351382.html
Copyright © 2011-2022 走看看