“Java:Module”与“HTTP/2”:页面之间的差异

来自WHY42
(页面间差异)
无编辑摘要
 
 
第1行: 第1行:
Java Platform Module System (JPMS)是Java9中的最大的变动,在[https://jcp.org/en/jsr/detail?id=376|JSR 376: JavaTM Platform Module System]中引入。


首先,模块化的jar文件(Modular JAR)中需要一个<syntaxhighlight lang="java" inline>module-info.class</syntaxhighlight>文件,这个文件里面存储了模块的信息。倘若没有,那么认为这是一个<syntaxhighlight lang="java" inline>automatic module</syntaxhighlight>,也即用jar的文件名作为模块来导出。
== HTTP/2 Discovery ==
;h2: HTTP/2 over TLS
;h2c: HTTP/2 is run over cleartext TCP


除此之外,jar文件中通过<span class="article-label">META-INF</span>目录存储安全、版本等其他信息
=== Starting HTTP/2 for "http" URIs===
如果客户端无法事先知道服务端是否支持http2,可以通过HTTP Upgrade mechanism(定义在HTTP/1.1)中来实现,这样在之后的请求中可以采取HTTP/2。


* MANIFEST.MF:定义package相关信息
<syntaxhighlight lang="lisp">
* INDEX.LIST:This file is generated by the new "-i" option of the jar tool, which contains location information for packages defined in an application.  It is part of the JarIndex implementation and used by class loaders to speed up their class loading process.
GET / HTTP/1.1
* The signature file for the JAR file. 'x' stands for the base file name.
Host: server.example.com
* x.DSA:The signature block file associated with the signature file with the same base file name. This file stores the digital signature of the corresponding signature file.
Connection: Upgrade, HTTP2-Settings
* services/:This directory stores all the service provider configuration files.
Upgrade: h2c
HTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload>
</syntaxhighlight>


这样的话,如果请求中由payload必须一次性发完。然后才能升级到HTTP/2。另一种办法是通过<span class="article-label">OPTIONS</span>请求
来判断,这样做会多一次请求。


[[Category:Java]]
如果服务端不支持HTTP/2,返回中则不包含Upgrade header:
 
<syntaxhighlight lang="lisp">
HTTP/1.1 200 OK
Content-Length: 243
Content-Type: text/html
</syntaxhighlight>
 
否则,返回一个101 (Switching Protocols)响应:
 
<syntaxhighlight lang="lisp">
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: h2c
</syntaxhighlight>
 
 
[[Category:Network]]

2021年6月22日 (二) 14:11的版本

HTTP/2 Discovery

h2
HTTP/2 over TLS
h2c
HTTP/2 is run over cleartext TCP

Starting HTTP/2 for "http" URIs

如果客户端无法事先知道服务端是否支持http2,可以通过HTTP Upgrade mechanism(定义在HTTP/1.1)中来实现,这样在之后的请求中可以采取HTTP/2。

GET / HTTP/1.1
Host: server.example.com
Connection: Upgrade, HTTP2-Settings
Upgrade: h2c
HTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload>

这样的话,如果请求中由payload必须一次性发完。然后才能升级到HTTP/2。另一种办法是通过请求 来判断,这样做会多一次请求。

如果服务端不支持HTTP/2,返回中则不包含Upgrade header:

HTTP/1.1 200 OK
Content-Length: 243
Content-Type: text/html

否则,返回一个101 (Switching Protocols)响应:

HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: h2c