zoukankan      html  css  js  c++  java
  • http协议-配置与调用

    Http协议:

                       1)http协议: 对浏览器客户端和服务器端之间数据传输的格式规范。

                       2)http请求:浏览器->服务器端

                                         格式:

                                                   请求行(请求方式(GET/POST) 请求资源(URI) http协议版本(http1.1))

                                                   请求头(键值对形式存在。 host、user-agent、referer)

                                                   一个空行

                                                   实体内容(POST提交的参数)

                                         HttpServletRequest对象: 请求对象。获取请求信息。

                                         请求行:request.getMethod()   request.getRequestURI/getRequestURL()  request.getProtocol();

                                         请求头: request.getHeader("name")    request.getHeaderNames() 

                                         实体内容: request.getInputStream()

                                         获取参数数据:(GET或POST)

                                                            request.getParameter("name")  一个值的参数

                                                            request.getParameterValues("name"); 多个值的参数

                                                            request.getParameterNames()    所有参数

                                                           

                       3)http响应: 服务器->浏览器端

                                         格式:

                                                   响应行(http协议版本 状态码 描述)

                                                            常用的状态码: 200   302  404   500

                                                   响应头( location(结合302状态码完成请求重定向功能)、 refresh(定时刷新)、content-type、content-disiposition(以下载方式打开))

                                                   一个空行

                                                   实体内容

                                         HttpServletResponse对象: 响应对象。设置响应信息。

                                                   响应行: response.setStatus();

                                                   响应头: response.setHeader("name","value")

                                                   实体内容:

                                                                     (PrintWriter) response.getWriter().writer(); 字符内容

                                                              (OutputStream)response.getOutputStream().writer();  字节内容

  • 相关阅读:
    drf中 连表深度查询和ListSerializer类包括drf中Response二次封装
    drf中表之间断关联操作
    drf中的序列化家族
    rest_framework框架的封装特点和APIView请求生命周期
    vue项目和django项目交互补充,drf介绍,restful规范
    Vue成绩单
    面向对象编程day2
    面向对象编程day3
    面向对象编程day1
    day13
  • 原文地址:https://www.cnblogs.com/chenzxl/p/7906417.html
Copyright © 2011-2022 走看看