Skip to content

Commit

Permalink
Merged branch 'jetty-10.0.x-more_docs' into 'jetty-10.0.x'.
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Feb 3, 2021
2 parents 0ccaa9f + 1f6c25c commit 4c67b88
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:revdate: {localdate}

:toc: left
:toclevels: 4
:toclevels: 5

:idseparator: -
:sectlinks:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link rel="stylesheet" href="../toc.css">
<script src="../toc.js"></script>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
:toc-title: Operations Guide
:breadcrumb: Home:../index.html | Operations Guide:./index.html
:idprefix: og-
:docinfo: private-head

include::../config.adoc[]
include::.asciidoctorconfig[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ Jetty supports ALPN and encrypted HTTP/2 with this configuration:
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=tlsALPNHTTP]
----

Note how the ``ConnectionFactory``s passed to `ServerConnector` are in order: TLS, ALPN, HTTP/1.1, HTTP/2.
Note how the ``ConnectionFactory``s passed to `ServerConnector` are in order: TLS, ALPN, HTTP/2, HTTP/1.1.

Jetty starts parsing TLS bytes so that it can obtain the ALPN extension.
With the ALPN extension information, Jetty can negotiate a protocol and pick, among the ``ConnectionFactory``s supported by the `ServerConnector`, the `ConnectionFactory` correspondent to the negotiated protocol.

The fact that the HTTP/2 protocol comes before the HTTP/1.1 protocol indicates that HTTP/2 is the preferred protocol for the server.

Note also that the default protocol set in the ALPN ``ConnectionFactory``, which is used in case ALPN is not supported by the client, is HTTP/1.1 -- if the client does not support ALPN is probably an old client so HTTP/1.1 is the safest choice.
26 changes: 26 additions & 0 deletions documentation/jetty-documentation/src/main/asciidoc/toc.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* ========================================================================
* Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
* ========================================================================
*/

.hidden {
display: none;
}
.toc-current {
font-weight: bold;
}
.toc-item {
padding-right: 0.4em;
}
.toc-toggle {
padding-right: 0.4em;
cursor: pointer;
}
121 changes: 121 additions & 0 deletions documentation/jetty-documentation/src/main/asciidoc/toc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//
// ========================================================================
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//

document.addEventListener('DOMContentLoaded', () => dynamicTOC());

function dynamicTOC() {
// Bind a click listener to all section titles.
const content = document.getElementById('content');
const sectionTitles = content.querySelectorAll('a.link');
for (const sectionTitle of sectionTitles) {
sectionTitle.addEventListener('click', event => collapseThenExpand(event.target.hash));
}

// Bind a click listener to all TOC titles.
const toc = document.getElementById('toc');
const tocTitles = toc.querySelectorAll('a');
for (const tocTitle of tocTitles) {
tocTitle.addEventListener('click', event => collapseThenExpand(event.target.hash));
}

// Add the icons to TOC nodes.
const nodes = toc.querySelectorAll('li');
for (const node of nodes) {
const span = document.createElement('span');
const css = span.classList;
if (node.querySelector(':scope > ul')) {
css.add('toc-toggle');
// Font-Awesome classes.
css.add('fa');
css.add('fa-caret-right');
span.addEventListener('click', event => toggle(event.target));
} else {
css.add('toc-item');
// The "icon" is the &bull; HTML entity.
span.appendChild(document.createTextNode('•'));
}
node.prepend(span);
}

collapseThenExpand(document.location.hash);
}

function collapseThenExpand(hash) {
const toc = document.getElementById('toc');
if (hash) {
const current = toc.querySelector('a.toc-current');
if (current) {
current.classList.remove('toc-current');
}
const anchor = toc.querySelector('a[href="' + hash + '"');
if (anchor) {
anchor.classList.add('toc-current');
collapse(toc);
expand(anchor.parentNode);
}
} else {
collapse(toc);
}
}

function collapse(node) {
const sections = node.querySelectorAll('ul');
for (const section of sections) {
const css = section.classList;
// Always show first levels TOC titles.
const alwaysShow = css.contains('sectlevel1') || css.contains('sectlevel2');
if (!alwaysShow) {
css.add('hidden');
}
}
// Show the collapsed icon.
const spans = node.querySelectorAll('span.toc-toggle');
for (const span of spans) {
const css = span.classList;
css.remove('fa-caret-down');
css.add('fa-caret-right');
}
}

function expand(node) {
const root = document.getElementById('toc').querySelector('ul');
// Show the current node and its ancestors.
let parent = node;
while (parent !== root) {
// Show the node.
parent.classList.remove('hidden');
// Show the expanded icon.
const span = parent.querySelector(':scope > span.toc-toggle');
if (span) {
const css = span.classList;
css.remove('fa-caret-right');
css.add('fa-caret-down');
}
parent = parent.parentNode;
}
// Show the children.
const children = node.querySelector(':scope > ul');
if (children) {
children.classList.remove('hidden');
}
}

function toggle(span) {
const css = span.classList;
const expanded = css.contains('fa-caret-down');
if (expanded) {
collapse(span.parentNode);
} else {
expand(span.parentNode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void tlsALPNHTTP() throws Exception
SslConnectionFactory tls = new SslConnectionFactory(sslContextFactory, alpn.getProtocol());

// The ServerConnector instance.
ServerConnector connector = new ServerConnector(server, tls, alpn, http11, h2);
ServerConnector connector = new ServerConnector(server, tls, alpn, h2, http11);
connector.setPort(8443);

server.addConnector(connector);
Expand Down

0 comments on commit 4c67b88

Please sign in to comment.