### Running Undertow Benchmarks via Command Line (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/benchmarks/README.md
This snippet provides the command-line instructions to build the Undertow project and then execute its benchmarks using the generated JAR file. It assumes Maven is installed for the 'mvn install' command, which compiles the project and packages the benchmarks.
```bash
mvn install
java -jar benchmarks/target/undertow-benchmarks.jar
```
--------------------------------
### Cloning Your Forked Undertow Repository
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command clones your newly forked Undertow repository from GitHub onto your local machine. Replace [your username] with your actual GitHub username. The `cd console` command then navigates into the cloned directory.
```bash
git clone git@github.com:[your username]/undertow.git
cd console
```
--------------------------------
### Building and Verifying Undertow Project
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This Maven command cleans the project and then runs the verification phase, which includes compiling, testing, and packaging the project. It ensures that all code changes build without errors and pass existing tests before committing.
```maven
mvn clean verify
```
--------------------------------
### Committing Changes with Verbose Output
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command commits the staged changes to your local repository. The `-v` (verbose) parameter is advisable as it displays the diff of the changes being committed, allowing you to review them while writing the commit message.
```bash
git commit -v
```
--------------------------------
### Viewing Detailed Git Commit History (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command displays the commit history along with the patch (diff) for each commit. It's useful for reviewing the exact changes introduced by each commit before pushing them, ensuring that only desired modifications are included.
```bash
git log -p
```
--------------------------------
### Creating a New Topic Branch
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command creates and switches to a new Git branch named `my_cool_feature`. It is recommended to create a simple topic branch to isolate your work, preventing direct changes on the main branch and facilitating easier PR management.
```bash
git checkout -b my_cool_feature
```
--------------------------------
### Switching to Master and Pulling Upstream Updates (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
These commands first switch the current working branch to `master`, then pull the latest changes from the `upstream` remote's `master` branch. This ensures the local `master` branch is up-to-date after a feature branch has been merged.
```bash
git checkout master
git pull upstream master
```
--------------------------------
### Adding Upstream Remote Reference
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command adds a remote reference named 'upstream' to the original Undertow repository. This makes it easy to pull down changes from the main project over time, keeping your local fork up-to-date.
```bash
git remote add upstream git://github.com/undertow-io/undertow.git
```
--------------------------------
### Pushing Current Branch to Origin (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command pushes the current branch to the `origin` remote. When no branch name is specified, Git pushes the current branch to its configured upstream branch on `origin`, typically updating the corresponding branch on GitHub.
```bash
git push origin
```
--------------------------------
### Creating a Topic Branch with Jira Number and Feature Name
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command creates and switches to a new Git branch, combining a Jira issue number (e.g., UNDERTOW-XXXX) with a descriptive feature name. This provides a comprehensive branch name for better tracking of changes linked to specific issues and features.
```bash
git checkout -b UNDERTOW-XXXX-my_cool_feature
```
--------------------------------
### Creating a Topic Branch with Jira Number (Short)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command creates and switches to a new Git branch, incorporating a Jira issue number (e.g., UNDERTOW-XXXX) into the branch name. This practice is highly useful for tracking changes related to specific issues and maintaining clear project organization.
```bash
git checkout -b UNDERTOW-XXXX
```
--------------------------------
### Interactively Rebasing Last X Commits (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command initiates an interactive rebase session for the last `X` commits on the current branch. It allows for advanced history rewriting operations such as amending, merging, deleting, or reordering commits. `X` should be replaced with the number of commits to rebase.
```bash
git rebase -i HEAD~X
```
--------------------------------
### Pushing Topic Branch to GitHub Remote (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command pushes the current topic branch to the `origin` remote, which typically corresponds to the user's GitHub repository fork. The branch name `UNDERTOW-XXXX-my_cool_feature` should be replaced with the actual topic branch name.
```bash
git push origin UNDERTOW-XXXX-my_cool_feature
```
--------------------------------
### Force Pushing Topic Branch to Origin (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command force pushes the specified topic branch to the `origin` remote. The `--foce` flag (likely a typo for `--force`) is necessary when the remote branch history has diverged from the local branch, typically after a rebase or amend operation, overwriting the remote history.
```bash
git push origin --foce UNDERTOW-XXXX-my_cool_feature
```
--------------------------------
### Pulling Updates from Upstream with Rebase
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command pulls the latest changes from the 'main' branch of the 'upstream' remote (the original Undertow repository) and rebases your local commits on top of them. The `--rebase` flag ensures your local commits are moved cleanly on top of the latest upstream changes, preventing merge conflicts.
```bash
git pull --rebase upstream main
```
--------------------------------
### Rebasing Local Branch Against Upstream Master (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command rebases the current local topic branch against the `master` branch of the `upstream` remote. It ensures that local commits are applied on top of the latest `master` changes, simplifying future merges and resolving potential conflicts early.
```bash
git pull --rebase upstream master
```
--------------------------------
### Amending the Latest Git Commit (Bash)
Source: https://github.com/undertow-io/undertow/blob/main/CONTRIBUTING.md
This command allows you to amend the most recent commit. It opens the commit message editor, allowing changes to the message and incorporating any staged changes into the previous commit. This is useful for minor corrections or additions to the last commit.
```bash
git commit --amend -v
```
--------------------------------
### Applying Global and Layout Styles - CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/sse/index.html
This CSS snippet defines global styles for the HTML and body elements, including full width and height, font settings, and a linear gradient background. It also includes basic reset rules for margins and paddings.
```CSS
html,body {width:100%;height:100%;}
html,body,ul,ol,dl,li,dt,dd,p,blockquote,fieldset,legend,img,form,h1,h2,h3,h4,h5,h6 {margin:0;padding:0;}
body { font:normal 12px/1.5 Arial,Helvetica,'Bitstream Vera Sans',sans-serif; background: #c5deea; /* Old browsers */ background: -moz-linear-gradient(top, #c5deea 0%, #066dab 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #c5deea), color-stop(100%, #066dab)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #c5deea 0%, #066dab 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #c5deea 0%, #066dab 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #c5deea 0%, #066dab 100%); /* IE10+ */ background: linear-gradient(to bottom, #c5deea 0%, #066dab 100%); /* W3C */ height: 90%; }
```
--------------------------------
### Initializing WebSocket Connection in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/websockets/index.html
This snippet initializes a WebSocket connection to a specified URL. It sets up event handlers for 'onmessage' (receiving data), 'onopen' (connection established), and 'onclose' (connection closed). It also includes a fallback alert for browsers without WebSocket support.
```JavaScript
var socket; if (window.WebSocket) { socket = new WebSocket("ws://localhost:8080/myapp"); socket.onmessage = function(event) { alert("Received data from websocket: " + event.data); }; socket.onopen = function(event) { alert("Web Socket opened!"); }; socket.onclose = function(event) { alert("Web Socket closed."); }; } else { alert("Your browser does not support Websockets. (Use Chrome)"); }
```
--------------------------------
### Initializing WebSocket Connection in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/websockets_extension/index.html
This snippet initializes a WebSocket connection to a specified URL (ws://localhost:8080/myapp) if the browser supports WebSockets. It sets up event handlers for onmessage (to process incoming data), onopen (on successful connection), and onclose (on connection termination). A fallback alert is provided for unsupported browsers.
```JavaScript
var socket;
if (window.WebSocket) {
socket = new WebSocket("ws://localhost:8080/myapp");
socket.onmessage = function(event) { alert("Received data from websocket: " + event.data); };
socket.onopen = function(event) { alert("Web Socket opened!"); };
socket.onclose = function(event) { alert("Web Socket closed."); };
} else {
alert("Your browser does not support Websockets. (Use Chrome)");
}
```
--------------------------------
### Defining Global HTML and Body Styles with Gradients in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/jsrwebsockets/index.html
This CSS snippet sets global styles for html and body elements, ensuring they occupy full width and height. It defines a default font and applies a cross-browser compatible linear gradient background, transitioning from light blue to dark blue.
```CSS
html,body {width:100%;height:100%;}
html,body,ul,ol,dl,li,dt,dd,p,blockquote,fieldset,legend,img,form,h1,h2,h3,h4,h5,h6 {margin:0;padding:0;}
body { font:normal 12px/1.5 Arial,Helvetica,'Bitstream Vera Sans',sans-serif; background: #c5deea; /* Old browsers */ background: -moz-linear-gradient(top, #c5deea 0%, #066dab 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #c5deea), color-stop(100%, #066dab)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #c5deea 0%, #066dab 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #c5deea 0%, #066dab 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #c5deea 0%, #066dab 100%); /* IE10+ */ background: linear-gradient(to bottom, #c5deea 0%, #066dab 100%); /* W3C */ height: 90%; }
```
--------------------------------
### Global HTML and Body Styling in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
This CSS snippet sets global styles for 'html' and 'body' elements, including full width/height, margin/padding resets, font properties, and a linear gradient background for the body, ensuring consistent page layout.
```CSS
html,body {width:100%;height:100%;} html,body,ul,ol,dl,li,dt,dd,p,blockquote,fieldset,legend,img,form,h1,h2,h3,h4,h5,h6 {margin:0;padding:0;} body { font:normal 12px/1.5 Arial,Helvetica,'Bitstream Vera Sans',sans-serif; background: #c5deea; /* Old browsers */ background: -moz-linear-gradient(top, #c5deea 0%, #066dab 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #c5deea), color-stop(100%, #066dab)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #c5deea 0%, #066dab 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #c5deea 0%, #066dab 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #c5deea 0%, #066dab 100%); /* IE10+ */ background: linear-gradient(to bottom, #c5deea 0%, #066dab 100%); /* W3C */ height: 90%; }
```
--------------------------------
### Initializing WebSocket Connection in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
This snippet initializes a WebSocket connection to 'ws://localhost:8080/myapp' if the browser supports WebSockets. It defines an 'onmessage' handler to append received data to a chat display and provides an alert for unsupported browsers.
```JavaScript
var socket; if (window.WebSocket) { socket = new WebSocket("ws://localhost:8080/myapp"); socket.onmessage = function (event) { var chat = document.getElementById('chat'); chat.innerHTML = chat.innerHTML + event.data + "
"; }; } else { alert("Your browser does not support Websockets. (Use Chrome)"); }
```
--------------------------------
### Initializing WebSocket Connection and Message Listener in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/jsrwebsockets/index.html
This JavaScript snippet initializes a WebSocket connection to ws://localhost:8080/myapp. It includes a fallback for browsers without WebSocket support and defines an onmessage handler to append incoming chat messages to an HTML element with the ID 'chat'.
```JavaScript
var socket;
if (window.WebSocket) {
socket = new WebSocket("ws://localhost:8080/myapp");
socket.onmessage = function (event) {
var chat = document.getElementById('chat');
chat.innerHTML = chat.innerHTML + event.data + "
";
};
} else {
alert("Your browser does not support Websockets. (Use Chrome)");
}
```
--------------------------------
### Initializing Server-Sent Events Listener - JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/sse/index.html
This JavaScript snippet initializes a Server-Sent Events (SSE) connection to receive real-time chat messages. It checks for browser support for EventSource and appends incoming messages to the 'chat' element. If SSE is not supported, it alerts the user.
```JavaScript
var socket; if (window.EventSource) { var source = new EventSource("sse"); source.onmessage = function(event) { var chat = document.getElementById('chat'); chat.innerHTML += event.data + "
"; }; } else { alert("Your browser does not support Server Sent Events. (Use Chrome)"); }
```
--------------------------------
### Styling Layout and Form Elements in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/jsrwebsockets/index.html
This CSS snippet defines styles for layout elements, including .center and .chatform classes for horizontal centering and width control. It also provides basic styling for form, label, and an input field with the ID #msg, ensuring proper display and width.
```CSS
.center { margin-left: auto; margin-right: auto; width: 70%; background: white; }
.chatform { margin-left: auto; margin-right: auto; margin-bottom: 0; width: 70%; }
form{ width: 100%; }
label{ display: inline; width: 100px; }
#msg{ display: inline; width: 100%; }
```
--------------------------------
### Styling Chat Container and Form - CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/sse/index.html
This CSS snippet defines styles for the chat container (`.center`) and the chat form (`.chatform`), centering them horizontally and setting their widths. It also includes basic styling for the form elements like `form`, `label`, and the message input field (`#msg`).
```CSS
.center { margin-left: auto; margin-right: auto; width: 70%; background: white; }
.chatform { margin-left: auto; margin-right: auto; margin-bottom: 0; width: 70%; }
form{ width: 100%; }
label{ display: inline; width: 100px; }
#msg{ display: inline; width: 100%; }
```
--------------------------------
### Sending Messages via WebSocket in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/websockets/index.html
This function sends a message over an established WebSocket connection. It first checks if WebSockets are supported and if the socket's 'readyState' is 'OPEN' before attempting to send the message. If the socket is not open, an alert is displayed.
```JavaScript
function send(message) { if (!window.WebSocket) { return; } if (socket.readyState == WebSocket.OPEN) { socket.send(message); } else { alert("The socket is not open."); } }
```
--------------------------------
### Sending Messages via WebSocket in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/websockets_extension/index.html
This function sends a message over an established WebSocket connection. It first checks for WebSocket API support and then verifies if the socket's readyState is OPEN before attempting to send the message. If the socket is not open, an alert is displayed.
```JavaScript
function send(message) {
if (!window.WebSocket) { return; }
if (socket.readyState == WebSocket.OPEN) {
socket.send(message);
} else {
alert("The socket is not open.");
}
}
```
--------------------------------
### Styling Chat Form Container in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
The '.chatform' class centers the chat form horizontally, sets its width to 70%, and removes any bottom margin, preparing it for user input elements.
```CSS
.chatform { margin-left: auto; margin-right: auto; margin-bottom: 0; width: 70%; }
```
--------------------------------
### Sending WebSocket Messages in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
This function sends a message over the established WebSocket connection. It checks for WebSocket support and ensures the socket is in an 'OPEN' state before sending, alerting the user if the socket is not ready.
```JavaScript
function send(message) { if (!window.WebSocket) { return false; } if (socket.readyState == WebSocket.OPEN) { socket.send(message); } else { alert("The socket is not open."); } return false; }
```
--------------------------------
### Centering Content Area in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
This CSS class '.center' is used to horizontally center a block element within its parent, setting its width to 70% and giving it a white background for visual separation.
```CSS
.center { margin-left: auto; margin-right: auto; width: 70%; background: white; }
```
--------------------------------
### Sending Chat Message via XMLHttpRequest - JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/sse/index.html
This JavaScript function sends a chat message to the server using XMLHttpRequest. It performs a POST request to the 'send' endpoint, setting appropriate headers for content type and length. It includes error handling for failed requests.
```JavaScript
function send(message) { if (!window.EventSource) { return false; } var http = new XMLHttpRequest(); http.open("POST", "send", true); http.setRequestHeader("Content-type", "test/plain"); http.setRequestHeader("Content-length", message.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() { if (http.readyState == 4 && http.status != 200) { alert("Failed to send chat message" + http.responseText); } } http.send(message); return false; }
```
--------------------------------
### Sending WebSocket Messages in JavaScript
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/jsrwebsockets/index.html
This JavaScript function, send(message), handles sending data over the established WebSocket connection. It checks if the WebSocket is open before sending the message and provides an alert if the socket is not in the OPEN state, returning false if WebSockets are not supported or the socket is closed.
```JavaScript
function send(message) {
if (!window.WebSocket) {
return false;
}
if (socket.readyState == WebSocket.OPEN) {
socket.send(message);
} else {
alert("The socket is not open.");
}
return false;
}
```
--------------------------------
### Styling Label Elements in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
This CSS rule styles 'label' elements to display inline with a fixed width of 100 pixels, suitable for aligning labels next to input fields.
```CSS
label{ display: inline; width: 100px; }
```
--------------------------------
### Styling Form Element in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
This CSS rule sets the 'form' element to occupy 100% of its parent's width, ensuring it spans the available horizontal space within its container.
```CSS
form{ width: 100%; }
```
--------------------------------
### Styling Message Input Field in CSS
Source: https://github.com/undertow-io/undertow/blob/main/examples/src/main/java/io/undertow/examples/chat/index.html
The '#msg' ID selector styles the message input field to display inline and take up 100% of its parent's width, allowing it to fill the available space for user input.
```CSS
#msg{ display: inline; width: 100%; }
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.