zoukankan      html  css  js  c++  java
  • 模拟get和post请求

    |------|get请求

    $get.php

    //php代码

    <?php


    //链接
    $fp = fsockopen('localhost',80,$errno,$errstr, 10);

    //判断
    if(!$fp){
    echo $errstr;die;
    }
    //模拟

    //1.请求行

    //Network  All  Request headers
    $str = "GET /%e5%a4%8d%e4%b9%a0/%e6%a8%a1%e6%8b%9fget%20post%e8%af%b7%e6%b1%82/server.php HTTP/1.1 ";
    //2.请求头

    //   换行  最后一个$str   两个
    $str .= "Host: localhost ";
    $str .= "Connection: close ";
    $str .= "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36 ";
    $str .= "Accept-Language: zh-CN,zh;q=0.9 ";
    $str .= "Cookie: age=20 ";

    $str .= "Referer: http://localhost/%e5%a4%8d%e4%b9%a0/%e6%a8%a1%e6%8b%9fget%20post%e8%af%b7%e6%b1%82/get.html ";

    //3.请求体
    // 写入信息
    fwrite($fp, $str);

    $res = '';
    while(!feof($fp)){
    $res .= fgets($fp);
    }

    echo $res;

    fclose($fp);
    ?>

    server.php

    <?php
    echo 123;

    var_dump($_COOKIE['age']);
    ?>

  • 相关阅读:
    gdb调试
    go pipeline
    Go的Timer
    goconvey
    购物
    Go的可行测试
    可能会停止一段时间的更新
    一些blog
    linux全套 | Python开发平台_Ubuntu | 15
    Python基础 | 配置pip镜像源 | 01
  • 原文地址:https://www.cnblogs.com/wwlong/p/10147726.html
Copyright © 2011-2022 走看看