<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>HTTP - 标签 - 研发日志 · R&amp;D Log</title><link>https://rd163.visword.com/tags/http/</link><description>HTTP - 标签 - 研发日志 · R&amp;D Log</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>whutluohui@gmail.com (小智晖)</managingEditor><webMaster>whutluohui@gmail.com (小智晖)</webMaster><copyright>本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可。</copyright><lastBuildDate>Wed, 19 Feb 2025 00:00:00 +0800</lastBuildDate><atom:link href="https://rd163.visword.com/tags/http/" rel="self" type="application/rss+xml"/><item><title>HttpAPI规范及生态组件</title><link>https://rd163.visword.com/posts/http-api-spec/</link><pubDate>Wed, 19 Feb 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/http-api-spec/</guid><description><![CDATA[<h2 id="背景" class="headerLink">
    <a href="#%e8%83%8c%e6%99%af" class="header-mark"></a>背景</h2><p>随着业务的增多，越来越多的服务需要提供 HTTP 协议的 API 接口供第三方调用。由于 HTTP API 并不像 tRPC 等协议那样有一套通用的协议规范来约束接口，API 开发者通常需要提供一份独立的 API 文档来说明每个接口的详细参数。</p>]]></description></item><item><title>Python HTTP 客户端库</title><link>https://rd163.visword.com/posts/python-http-client-libs/</link><pubDate>Wed, 15 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/python-http-client-libs/</guid><description><![CDATA[<h2 id="urlliburllib2" class="headerLink">
    <a href="#urlliburllib2" class="header-mark"></a>urllib、urllib2</h2><p>Python 2 时代常用的标准库 HTTP 客户端是 <code>urllib</code> 和 <code>urllib2</code>,它们提供了 URL 编码、请求构造、认证、重定向等基础能力，让我们能在不依赖第三方库的情况下完成大多数 HTTP 调用。两者的分工略有差异:<code>urllib</code> 偏向基础 URL 处理,<code>urllib2</code> 则在请求定制（如自定义 header、handler、opener）上更强大。</p>]]></description></item><item><title>CSRF 跨站请求伪造详解</title><link>https://rd163.visword.com/posts/http-csrf/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/http-csrf/</guid><description><![CDATA[<h2 id="简介" class="headerLink">
    <a href="#%e7%ae%80%e4%bb%8b" class="header-mark"></a>简介</h2><p>CSRF(Cross-Site Request Forgery，跨站请求伪造)是一种针对 Web 应用的攻击方式。攻击者诱导已登录（已通过身份认证）的用户，在他们不知情的情况下，以其身份向目标网站发送了一个恶意请求。由于浏览器在跨站请求中<strong>会自动携带目标域的 Cookie</strong>,服务器看到请求带着有效的会话凭证，就会把它当作合法用户本人的操作并予以执行。</p>]]></description></item><item><title>Golang web框架</title><link>https://rd163.visword.com/posts/golang-web-framework/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-web-framework/</guid><description><![CDATA[<h2 id="fiber" class="headerLink">
    <a href="#fiber" class="header-mark"></a>Fiber</h2><ul>
<li><a href="https://github.com/gofiber/fiber" target="_blank" rel="noopener noreferrer">Fiber</a>:受 Express.js 启发的 Go Web 框架，底层基于 fasthttp，主打零内存分配与高性能。</li>
</ul>
<p>基于 Fiber 的开源项目:</p>
<ul>
<li><a href="https://github.com/Finb/bark-server" target="_blank" rel="noopener noreferrer">bark-server</a>:iOS 推送通知服务 Bark 的后端。</li>
</ul>
<h2 id="macaron" class="headerLink">
    <a href="#macaron" class="header-mark"></a>Macaron</h2><ul>
<li><a href="https://github.com/go-macaron/macaron" target="_blank" rel="noopener noreferrer">Macaron</a>:高生产力、模块化的 Go Web 框架。目前已进入维护模式，不再新增功能，官方推荐其后继者 <a href="https://github.com/flamego/flamego" target="_blank" rel="noopener noreferrer">Flamego</a>。</li>
</ul>
<h2 id="beego" class="headerLink">
    <a href="#beego" class="header-mark"></a>Beego</h2><ul>
<li><a href="https://github.com/beego/beego" target="_blank" rel="noopener noreferrer">Beego</a>:老牌高性能 Go Web 框架，提供 ORM、缓存、日志、配置、任务等一整套模块。注：原作者仓库 <code>astaxie/beego</code> 已迁移至 <code>beego/beego</code> 组织，请使用新地址。</li>
</ul>
<h2 id="gin" class="headerLink">
    <a href="#gin" class="header-mark"></a>Gin</h2><ul>
<li><a href="https://github.com/gin-gonic/gin" target="_blank" rel="noopener noreferrer">Gin</a>:使用最广泛的 Go Web 框架，采用 httprouter 改造的路由，性能高、API 简洁，中间件生态丰富。</li>
</ul>
<h2 id="echo" class="headerLink">
    <a href="#echo" class="header-mark"></a>Echo</h2><ul>
<li><a href="https://github.com/labstack/echo" target="_blank" rel="noopener noreferrer">Echo</a>:高性能、极简的 Go Web 框架，自动 TLS、HTTP/2、可扩展中间件支持完善。</li>
</ul>
<h2 id="chi" class="headerLink">
    <a href="#chi" class="header-mark"></a>Chi</h2><ul>
<li><a href="https://github.com/go-chi/chi" target="_blank" rel="noopener noreferrer">chi</a>:轻量、兼容 <code>net/http</code> 的路由库，API 与标准库无缝衔接，适合构建可组合的 HTTP 服务。</li>
</ul>
<h2 id="gorilla" class="headerLink">
    <a href="#gorilla" class="header-mark"></a>Gorilla</h2><ul>
<li><a href="https://github.com/gorilla/mux" target="_blank" rel="noopener noreferrer">gorilla/mux</a>:强大的 HTTP 路由与请求匹配器，功能丰富。Gorilla 工具集曾在 2022 年底被归档，后由新的维护者团队接管并恢复维护。</li>
<li><a href="https://github.com/gorilla/websocket" target="_blank" rel="noopener noreferrer">gorilla/websocket</a>:Go 社区应用最广泛的 WebSocket 库。</li>
</ul>
<h2 id="fasthttp" class="headerLink">
    <a href="#fasthttp" class="header-mark"></a>fasthttp</h2><ul>
<li><a href="https://github.com/valyala/fasthttp" target="_blank" rel="noopener noreferrer">fasthttp</a>:为极端性能优化的 HTTP 实现，吞吐量与内存占用均显著优于标准库 <code>net/http</code>,但 API 与 <code>net/http</code> 不兼容。</li>
</ul>
<h2 id="httprouter" class="headerLink">
    <a href="#httprouter" class="header-mark"></a>httprouter</h2><ul>
<li><a href="https://github.com/julienschmidt/httprouter" target="_blank" rel="noopener noreferrer">httprouter</a>:基于 radix tree 的高性能路由，是众多 Go Web 框架（含 Gin）的底层路由原型。</li>
</ul>
<h2 id="hertz" class="headerLink">
    <a href="#hertz" class="header-mark"></a>Hertz</h2><p>Hertz(发音 [həːts],赫兹)是字节跳动开源的 Golang 微服务 HTTP 框架，由 <a href="https://github.com/cloudwego" target="_blank" rel="noopener noreferrer">CloudWeGo</a> 社区维护。它最初 fork 自 fasthttp，在设计上参考了 Gin、Echo 等开源框架的优势，并结合字节跳动内部对高性能与可扩展性的诉求进行了重构与演进。其默认网络库使用 CloudWeGo 自研的 <a href="https://github.com/cloudwego/netpoll" target="_blank" rel="noopener noreferrer">Netpoll</a>(基于 epoll),并保留了切换至 Go 标准网络库的能力，具有高易用性、高性能、高扩展性等特点，目前在字节跳动内部已大规模使用。</p>]]></description></item><item><title>HTTP 相关的 C 库：libmicrohttpd 与 libcurl</title><link>https://rd163.visword.com/posts/http-libs/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/http-libs/</guid><description><![CDATA[<p>在 C/C++ 项目里，如果只想做最简单的 HTTP 收发，往往不必引入一整套 Web 框架。根据角色不同，常用的有两类基础库：</p>
<ul>
<li><strong>服务端库（HTTP server）</strong>：把 HTTP 协议层封装好，让应用嵌入一个监听端口、处理请求的逻辑，典型代表是 GNU 的 <strong>libmicrohttpd</strong>。</li>
<li><strong>客户端库（HTTP client）</strong>：负责发起请求、处理重定向、TLS、Cookie 等，事实标准是 <strong>libcurl</strong>。</li>
</ul>
<p>下面分别记录这两组库的要点，作为日后选型与查阅的索引。</p>]]></description></item><item><title>Open Graph Protocol（开放图谱协议）</title><link>https://rd163.visword.com/posts/open-graph-protocol/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/open-graph-protocol/</guid><description><![CDATA[<h2 id="简介" class="headerLink">
    <a href="#%e7%ae%80%e4%bb%8b" class="header-mark"></a>简介</h2><p>Open Graph Protocol（开放图谱协议），简称 <strong>OG 协议</strong>，是一种网页元信息（Meta Information）标记协议，属于 Meta Tag（Meta 标签）范畴。它最早由 Facebook 在 2010 年的 F8 开发者大会上公布，目标是<strong>为社交分享而生</strong>：通过一组 <code>&lt;meta&gt;</code> 标签标准化网页的元数据使用，让社交媒体平台能够以丰富的&quot;图形对象（Graph Object）&ldquo;形式来表示被分享的页面内容，使其他网站的内容也能像平台原生内容一样被呈现，进而促进站点与社交平台之间的集成。</p>]]></description></item><item><title>跨域资源共享 CORS 详解</title><link>https://rd163.visword.com/posts/http-cors/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/http-cors/</guid><description><![CDATA[<h2 id="简介" class="headerLink">
    <a href="#%e7%ae%80%e4%bb%8b" class="header-mark"></a>简介</h2><p>CORS(Cross-Origin Resource Sharing，跨域资源共享)是一个基于 HTTP 头的安全机制，允许服务器声明浏览器可以从<strong>哪些源（origin）</strong> 加载自己提供的资源。源由 <strong>协议（scheme）、域名（host）和端口（port）</strong> 三者共同决定，任一不同即视为跨域。</p>]]></description></item></channel></rss>