- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
在 Reference of HttpRequest.HttpMethod
在 .NET Framework 中,请求类型声明为 System.String
类型。
在 RFC 2616声明了所有 HTTP 请求方法(例如 POST、GET、PUT、DELETE...)。
HttpWebRequest
中也有类似的行为和 .NET 的 WebRequest
类。
Java 在 HttpURLConnection#setRequestMethod(String)
上有类似的方法方法。
为什么这些语言设计者不考虑为这些 HTTP 方法实现枚举?
你有什么想法吗?
最佳答案
你的 RFC 2616 的第一句话链接(强调):
The set of common methods for HTTP/1.1 is defined below. Although this set can be expanded...
也就是说,HTTP 中的方法可以是任何东西。有一些“众所周知”或常用的方法,它们的语义很好理解(嗯,好吧,应该很好理解 - 我仍然遇到在 GET/POST 上不清楚的人)。
但是任何应用程序都可以实现其他方法。希望客户端和服务器应用程序之间能够很好地理解这些其他方法的语义。
由于这些原因,枚举是不合适的,因为总是有“其他”值不适合该枚举。
来自 RFC 2616 的更多报价:
Practical information systems require more functionality than simple retrieval, including search, front-end update, and annotation. HTTP allows an open-ended set of methods and headers that indicate the purpose of a request
和,
The Method token indicates the method to be performed on the resource identified by the Request-URI. The method is case-sensitive.
Method = "OPTIONS" ; Section 9.2
| "GET" ; Section 9.3
| "HEAD" ; Section 9.4
| "POST" ; Section 9.5
| "PUT" ; Section 9.6
| "DELETE" ; Section 9.7
| "TRACE" ; Section 9.8
| "CONNECT" ; Section 9.9
| extension-method
extension-method = token
关于java - 为什么 HttpRequest.HttpMethod 是字符串而不是枚举?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6722248/
假设我的客户端(浏览器)请求我的 java 服务(服务 A)。 http://localhost:8080/getDataFromB 根据服务 A 的请求,我需要向服务 B 或服务 C 发出另一个 H
我正在尝试调用 API 来检索数据列表,此数据将帮助我获取图像源。因此,对于每个数据条目,我尝试调用图像 url 并使用 Parse Image 进行一些图像处理。问题是,内部的 httpReques
当前代码 if (!(context.Exception is exception)) HttpContent requestContent = context.Request.Content
我有这个代码: You are browsing this site with: Or with Request.UserAgent: 第一个在浏览器
我正在使用 Django 和 TornadIO2/Tornado 编写一个 socket.io 应用程序。在 TonradIO2 session 中,我可以访问 Tornado 的 HTTPReque
用于确定用户代理的这两个属性之间有什么区别(如果有)和优点/缺点? Dim strUserAgt as String userAgent = Request.userAgent 对比 Dim strU
详情如下:https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httprequest?view=aspnetco
我一直在关注我网站的性能,在所有执行缓慢的代码 (>1s) 中,超过 90% 是因为 System.Web.HttpRequest.GetEntireRawContent()(由 System.Web
我有一个后端服务,它接受授权 header 来验证访问。我使用 Spring cloud zuul 创建了一个网关服务,并将请求路由到后端服务。 网关服务本身受 OAuth2 保护,并接受授权 hea
是否可以在中间件函数中获取请求方法(GET、POST、PUT...)? $myMiddleware = function (Request $request) { // This is wha
代码如下: //Get请求方式 private string RequestGet(string Url) &n
在 .net Framework yield ok. // if is not valid var request = HttpContext.Current.Req
在用于 http get 和 post 的 angular 5.2.x 中,我有以下代码: post(url: string, model: any): Observable { return thi
我试图了解如何从Dart进行Ajax调用。我对Web编程的了解非常有限。 我的简单服务器ajax.py:- #!/usr/bin/env python from datetime import tim
我正在为Http GET请求创建包装器类,但是当我使用HttpRequest.request时,没有任何响应。如果我使用原始的HttpRequests使用等效的代码,则可以使用。 我想念什么吗?我正在
我正在尝试生成一个 jmeter 脚本,其中每次运行脚本时都会创建一个唯一的文件夹 - 将某种变量添加到文件夹名称中,例如用户名+时间戳,应该足以保证唯一性。然而,jmeter 并没有将变量解析为其值
我有一个网络应用程序,它有一个计时器,每 3 秒触发一次轮询以获取数据。它工作正常大约 2.5 分钟,然后 Chromium 崩溃。 我的请求 Dart 看起来像这样 HttpRequest.getS
我目前有一个函数,可以生成 httpRequest 并将接收到的 json 解析为 URL array 。我想在第一个请求完成并且数据解析后触发第二个 httpRequest ,在我尝试过的两种解决方
我试图像这样延迟我的 $http 调用: githubService.getUserEvents = function getUserEvents() { return $timeout
我正在运行 340 个并发用户以使用 jmeter 在服务器上进行负载测试。 但是在大多数情况下,jmeter 挂断并且不会返回,即使我尝试关闭连接它也只是挂断了。最终我不得不关闭应用程序。 任何想法
我是一名优秀的程序员,十分优秀!