HTTP 数据协商

openharmony 软总线-设备发现流程 message取值描述1协商请求消息2客户端确认消息32769协商回应消息32770服务端确认消息32896当异常发生时,使用这条消息通知对方异常错误码描述FAILED0x00000001操作失败0x80000001请求被拒绝0x80000003请求未找到0x80000005请求被调用者拒绝0xF0000001非法参数TIMEOUT0xF0000003请求超时0xF000000A版本与对端不对应0xF000000B接收的数据内容格式不符合预期。 阅读详情

数据协商,即客户端发送给服务端一个请求的时候,客户端会申明希望拿到的数据的格式以及数据相关的一些限制,而服务端会根据这些请求中表示的想要的限制,来进行判断要返回一个怎样的数据。

分类

 - 请求 Accept

    通过 “Accept” 申明希望的数据的格式

    通过 “Accept-Encoding” 申明希望的数据的编码方式(主要用来限制服务端如何进行数据的压缩)

    通过 “Accept-Language” 申明希望的语言

    通过 “User-Agent” 申明浏览器相关信息(比如移动端,PC端)

 - 返回 Content

    通过 “Content-Type” 对应数据格式(参考MIME Type)

    通过 “Content-Encoding” 对应数据的编码方式

    通过 “Content-Language” 对应语言

 

下面,我们来实验一下。

先是server.js 如下。

const http = require('http')
const fs = require('fs')

http.createServer(function (request, response) {
    console.log('request come', request.url)

    const html = fs.readFileSync('test.html', 'utf8')
    response.writeHead(200, {
        'Content-Type': 'text/html'
    })
    response.end(html)
    
}).listen(8888)

console.log('serve listening on 8888')

然后是 test.html ,如下。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>MyHtml</title>
</head>
<body>
    <div>hello world</div>
    <div>don't speak</div>
</body>
</html>

然后,我们启动项目,访问localhost:8888 。打开控制台 network 会看到:(q 代表权重)

 

其他点:

关于 Content-Type,我们可以会用到一个Response Header “X-Content-Type-Options”,如下。(在很早之前,返回了Content-Type申明了一种数据类型,IE 浏览器也会不接受而主动地预测返回的数据是怎样的类型,这会导致一些安全性问题,申明了这个头且值为‘nosniff’ 浏览器就不会那么做了)

const http = require('http')
const fs = require('fs')

http.createServer(function (request, response) {
    console.log('request come', request.url)

    const html = fs.readFileSync('test.html', 'utf8')
    response.writeHead(200, {
        'Content-Type': 'text/html',
        'X-Content-Type-Options': 'nosniff'
    })
    response.end(html)
    
}).listen(8888)

console.log('serve listening on 8888')

数据压缩

我们先看看未压缩的时候数据的大小,localhost 是 455B

压缩代码,如下

const http = require('http')
const fs = require('fs')
const zlib = require('zlib')

http.createServer(function (request, response) {
    console.log('request come', request.url)

    const html = fs.readFileSync('test.html')
    response.writeHead(200, {
        'Content-Type': 'text/html',
        'Content-Encoding': 'gzip'
    })
    response.end(zlib.gzipSync(html))
    
}).listen(8888)

console.log('serve listening on 8888')

我们重启服务,查看文件的大小如下。

最后,发送请求时的“Content-Type”(实际上是会在response阶段体现的)

我们在html页面上新建表单如下。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>MyHtml</title>
</head>
<body>
    <div>hello world</div>
    <div>don't speak</div>
    <form action="/form" method="POST" enctype="application/x-www-form-urlencoded">
        <input type="text" name="name"/>
        <input type="password" name="password"/>
        <input type="submit" />
    </form>
</body>
</html>

那么我们就可以看到下面这样的network

当我们要传文件的时候,可以这样

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>MyHtml</title>
</head>
<body>
    <div>hello world</div>
    <div>don't speak</div>
    <form id="form" action="/form" method="POST" enctype="multipart/form-data">
        <input type="text" name="name"/>
        <input type="password" name="password"/>
        <input type="file"/>
        <input type="submit" />
    </form>

    <script>
        var form = document.getElementById('form')
        form.addEventListener('submit', function (e) {
            e.preventDefault()
            var formData = new FormData(form)
            fetch('/form', {
                method: 'POST',
                body: formData
            })
        })
    </script>
</body>
</html>

 

解密OpenHarmony设备发现协议:从SSID字段到SPEKE安全协商的全流程剖析 本文深度解析OpenHarmony设备发现协议,从SSID字段的二进制结构设计到SPEKE安全协商的全流程。详细介绍了多协议协同发现、结构化标识编码及动态功耗管理等核心技术,并剖析了SPEKE协议的数学实现与安全握手过程,为开发者提供全面的技术参考与实践指南。 阅读详情

相关推荐

解密OpenHarmony设备安全协商:从SPEKE算法到证书认证的完整链路

本文深入解析OpenHarmony设备安全通信全链路,从SPEKE密钥协商协议到多级CA证书认证体系,揭示其在物联网环境中的安全设计哲学与实践。通过分层加密、自适应安全策略和防御矩阵构建,OpenHarmony为各类设备提供灵活且强大的安全防护方案,确保智能生态系统的通信安全。

weixin_29266647的博客 219

使用requests库发送请求时,期望返回的header中包含‘x-content-type-options‘

为了解决这个问题,我手动设置了'x-content-type-options'字段的值为'nosniff',以确保浏览器在接收到响应时执行严格的MIME类型检查。为了解决这个问题,我需要手动设置'x-content-type-options'字段的值为'nosniff',以确保浏览器在接收到响应时执行严格的MIME类型检查。然而,根据我的观察,当我使用requests 2.20.0版本发送请求时,响应的header中没有包含'x-content-type-options'字段,这可能会导致潜在的安全问题。

w15189597283的博客 2150

从CST到AD:高效PCB阵列设计与介质优化实战

本文详细解析了从CST电磁仿真软件到Altium Designer(AD)的PCB阵列设计全流程,重点解决毫米波天线等精密设计中模型导出、介质优化和阵列构建的核心难题。通过实战技巧,指导工程师高效处理DXF文件导入、复杂铜皮填充、空气介质实现等关键步骤,确保高精度设计从仿真到制造的顺利转换,提升工作效率与设计可靠性。

weixin_28256233的博客 438

测试(绿盟)

测试(绿盟) 绿盟科技漏洞报告,IIS 修复 web.config 配置 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <security> <requestFiltering> <requestLimits> &lt

hello.reader 2973

PyTorch实战:用FGSM攻击MNIST分类器(附可视化对比)

本文通过PyTorch实战演示了如何使用FGSM对抗攻击方法攻击MNIST手写数字分类器。文章详细解析了FGSM攻击原理,提供了从环境搭建、模型准备到攻击实施、可视化对比的完整代码实战流程,并探讨了对抗样本的生成与模型鲁棒性评估。

3a9bq4r8t2y的博客 216

智能农业大棚

目 录 摘要 1.绪论 2.系统概述及单片机介绍 2.1整体方案设计思想 2.2系统组成 2.2.1主控芯片的选择 2.2.2传感器模块选择 2.2.3电机驱动模块 2.3 单片机介绍 2.3.1 AT89C51单片机的基本组成 2.3.2AT89C51主要特性 2.3.3管脚说明 2.3.4 AT89C51单片机的存储器 2.3.4.1 程序存储器 2.3.4.2 数据存储器 2.3.5 振荡电路和时钟 2.3.6 AT89C51的中断

weixin_70886450的博客 1327

HTTP之数据协商

文章目录什么是数据协商类型分类请求类型AcceptAccept-EncodingAccept-LanguageUser-Agent返回类型ContentContent-TypeContent-EncodingContent-Language源码使用方法文件的具体内容常用的MIME 什么是数据协商 客户端发送一个请求的时候,会在请求头中声明,我此次请求想拿到的数据格式和一些其他内容的限制,而服务端会...

BREATH57的博客 414

使用GitLab+Drone CI持续集成自动部署web项目,图文详细

kind: pipeline # 定义对象类型,还有secret和signature两种类型 type: docker # 定义流水线类型,还有kubernetes、exec、ssh等类型 name: mall-tiny-drone # 定义流水线名称 steps: # 定义流水线执行步骤,这些步骤将顺序执行 - name: package # 流水线名称 image: maven:3-jdk-8 # 定义创建容器的Docker镜像 volumes: # 将容器内目录挂载到宿主机,仓库

4105

深入HTTP-数据协商

数据协商 客户端发送请求给服务器,客户端会声明请求希望拿到的数据的格式和限制,服务端会根据请求头信息来决定返回的信息 分类 请求 Accept 返回 Content Accept Accept–声明想要数据的类型 Accept-Encoding–数据以哪种编码方式进行传输,限制服务端如何进行数据压缩 Accept-Language–展示语言 User-Agent–浏览器相关信息,移动端,客户端...

追梦的小狼狗 157

基于simulink的BMS系统中电池单体故障隔离与恢复建模

本文介绍了使用Simulink构建BMS电池单体故障诊断与容错控制模型的方法。主要内容包括:1)搭建12串锂电池组模型;2)实现单体故障注入(过压、断线等);3)设计故障诊断与隔离模块(采用Stateflow状态机);4)开发恢复判断逻辑(需满足电压、温度等条件);5)系统监控与仿真设置。文章还提供了工程实践建议,如防环流设计、通信冗余等,并指出进阶方向(多故障处理、AI预警等)。该模型适用于新能源汽车、储能系统的BMS设计,可提高系统可靠性和安全性。

xiaoheshang_123的博客 140

YOLOv11知识蒸馏,实现无损涨点,包含逻辑蒸馏和特征蒸馏中的不同蒸馏方法,适用专栏内的所有模型

知识蒸馏(Knowledge Distillation)是由 Hinton 等人在 2015 年提出来的,主要是用一个复杂的教师模型去指导一个简单的学生模型训练,这样能让学生模型在保持高精度的同时,还能减少计算量。本文便是讲解如何针对的原始模型以及改进后的模型进行知识蒸馏,轻松实现无损涨点。知识蒸馏的核心在于利用已训练好的复杂模型(教师模型)去指导一个更简单的模型(学生模型)进行训练,以此让学生模型在保留较高精度的同时,降低计算成本。特征蒸馏(Feature Distillation)是知识蒸馏的一种形式,

Limiiiing的博客 4959

http数据协商

数据协商的概念 客户端发送请求给服务端,客户端会声明请求希望拿到的数据的格式和限制,服务端会根据请求头信息,来决定返回的数据。 分类 请求 Accept 返回 Content Accept Accept 声明想要数据的类型 Accept-Encoding 数据以哪种编码方式传输,限制服务端如何进行数据压缩。 Accept-Language 展示语言 User-Agent 浏览器相关信息,移动端、客...

littlebirdflying的博客 512

ROS2 Nav2 - 模型预测路径积分控制器(MPPI)

这是一个预测控制器(局部轨迹规划器),用于实现模型预测路径积分(MPPI)算法,以跟踪具有自适应避障功能的路径。它包含基于插件的 critic 函数,可影响算法的行为。它由 Aleksei Budyakov 创建,由 Steve Macenski 为 Nav2 进行改编和开发。该插件实现了 nav2_core::Controller(控制器)接口,可在整个导航堆栈中作为控制器服务器的动作服务器(controller_server)中的局部轨迹规划器使用。据测定,该控制器可在中等英特尔处理器(第四代 i5)上

机器人控制与仿真应用 3907

HTTP 数据协商(内容协商)

HTTP常见请求头和响应头如下:

mangoyiy的博客 1660

基于51单片机设计的花样流水灯设计

花样流水灯是一种常见的LED灯效果,通常由多个LED灯组成,通过控制每个LED灯的亮灭顺序和时间,实现花样流水灯的效果。在51单片机中,可以使用定时器和端口控制来实现这一效果。

3428

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

http协议_数据协商

http协议中,可以通过内容协商返回最合适的内容,例如根据浏览器的默认语言选择返回中文界面还是英文界面。 在客户端发送给服务端一个请求的时候,客户端可以声明该请求所期望获得的数据格式和数据相关的一些属性,服务端会根据客户端声明的请求做出判断并给出相应的结果 实现方式一: 客户端设置特定的 HTTP 首部字段,例如 Accept、Accept-Charset、Accept-Encoding、A...

coding 325

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

HTTP协议特性之数据协商——NodeJs版

一、什么是数据协商呢? 在客户端发送请求给服务端的时候,客户端会声明它想要拿到的数据格式 以及 数据相关的限制。服务器则以此为线索,通过内部算法来选择最佳方案提供给客户端。相关算法与具体的服务器相关,并没有在规范中进行规定。 二、参数介绍 1、客户端 1)Accept Accept 首部列举了用户代理希望接收的媒体资源的 MIME 类型 2)Accept-Encoding Acc...

Science Explorer 299

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

关于HTTP中的数据协商

关于数据协商 在客户端发送给服务端一个请求的时候,客户端会声明通过这个请求拿到的数据格式以及数据相关的一些限制要求 服务端会有很多不同类型的数据返回,它会根据请求的这个声明做出一个判断,根据请求头信息来区分返回数据 分类 请求 1 ) 客户端请求中通过Accept来声明我想要什么样的数据,Accept指定数据类型 这个数据类型会根据MineType的声明进行一个限制, 来告诉服务端想要的数据类型 2 ) 通过Accept-Encoding代表数据是一个怎样的编码方式来进行传输 主要用来限制服务端如何来

Wang的专栏 822

HTTP(Ⅸ)—— 数据协商

在客户端向服务器发送请求的时候,会告诉服务器我想要拿到的数据格式,以及数据相关的限制,服务端会根据他的请求,做出判断,然后决定要返回什么样子的数据。这就是数据协商上。 请求的Accept Accept:表示的是我想要什么类型的数据 Accept-Encoding:表示我想要数据的编码方式 Accept-Language:返回数据数据语言 User-Agent:表示浏览器的相关信息,来判断...

zhanghuali 298

接受body数据_HTTP总结(七):数据协商、Redirect

在客户端发送给服务端请求的时候,客户端会声明:我希望这个请求我拿到的数据格式以及数据相关的一些限制是怎样的。服务端会根据这个做出判断要返回怎样的数据。分类请求:通过Accept来声明想要的数据Accept:指定想要的类型 好几种格式Accept-Encoding:数据的编码方式,限制服务端进行数据的压缩Accept-Language:中文、英文等User-Agent:浏览器的信息返回:Conten...

weixin_36429611的博客 240

HTTP--http之数据协商(八)

Accept接收 Accept 可接受的响应内容类型(Content-Types)。 Accept-Encoding 可接受的响应内容的编码方式。 Accept-Language 可接受的响应内容语言列表。 User-Agent 浏览器的身份标识字符串 Content 响应 Content-Type ...

weixin_34310127的博客 122

HTTP的实体数据

它表示浏览器最希望使用的是 HTML 文件,权重是 1,其次是 XML 文件,权重是 0.9,最后是任意数据类型,权重是 0.8。不过现在的浏览器都支持多种字符集,通常不会发送 Accept-Charset,而服务器也不会发送 Content-Language,因为使用的语言完全可以由字符集推断出来,所以在。字段标记的是客户端支持的压缩格式,例如上面说的 gzip、deflate 等,同样也可以用“,”列出多个,服务器可以选择其中一种来压缩数据,实际使用的压缩格式放在响应头字段。

2301_81948543的博客 1273

HTTP系列五、HTTP的Body体的内容协商

常见的有 application/json,application/javascript、application/pdf 等,另外,如果实在是不知道数据是什么类型,像刚才说的“黑盒”,就会是 application/octet-stream,即不透明的二进制数据。但仅有 MIME type 还不够,因为 HTTP 在传输时为了节约带宽,有时候还会压缩数据,为了不要让浏览器继续“猜”,还需要有一个“Encoding type”,告诉数据是用的什么编码格式,这样对方才能正确解压缩,还原出原始的数据。

勇心在馨 1087

【学习笔记】透视HTTP协议(十一):HTTP的实体数据

HTTP通过MIME类型、编码类型、语言类型和字符集等机制,实现了对实体数据的精确描述和处理。这些机制使得HTTP能够支持各种类型的数据传输,满足多样化的需求。数据类型:使用MIME type描述,相关头字段为Accept和。数据编码:使用Encoding type描述,相关头字段为和。语言类型:使用自然语言描述,相关头字段为和。字符集:使用字符集描述,相关头字段为和。内容协商:客户端通过Accept等头字段与服务器协商,要求返回最合适的数据。

MAOZI8的博客 900
上一篇: HTTP 长连接
下一篇: HTTP Redirect
purple_lumpy
博客等级 码龄10年 73粉丝 340原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值