or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

compression-utilities.mdcontent-management.mdcookie-handling.mdhttp-headers.mdhttp-methods-status.mdhttp-parsing-generation.mdindex.mdmultipart-processing.mdpath-mapping.mduri-processing.md
tile.json

tessl/maven-org-eclipse-jetty--jetty-http

Core HTTP protocol support library for Eclipse Jetty providing header handling, parsing, generation, compliance validation, and content processing capabilities

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.eclipse.jetty/jetty-http@12.0.x

To install, run

npx @tessl/cli install tessl/maven-org-eclipse-jetty--jetty-http@12.0.0

index.mddocs/

Jetty HTTP

Jetty HTTP is the core HTTP protocol support library for Eclipse Jetty, providing comprehensive HTTP processing capabilities including header handling, parsing, generation, compliance validation, compression utilities, content management, and path mapping. It serves as the foundation for HTTP clients and servers with optimized performance and zero-copy buffer management.

Package Information

  • Package Name: org.eclipse.jetty:jetty-http
  • Package Type: Maven
  • Language: Java
  • Installation:
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-http</artifactId>
      <version>12.0.21</version>
    </dependency>

Core Imports

import org.eclipse.jetty.http.*;
import org.eclipse.jetty.http.pathmap.*;
import org.eclipse.jetty.http.compression.*;
import org.eclipse.jetty.http.content.*;

Basic Usage

import org.eclipse.jetty.http.*;

// Create and manipulate HTTP headers
MutableHttpFields headers = new MutableHttpFields();
headers.put(HttpHeader.CONTENT_TYPE, "application/json");
headers.put(HttpHeader.CACHE_CONTROL, "no-cache");

// Parse HTTP method and status
HttpMethod method = HttpMethod.fromString("POST");
int statusCode = HttpStatus.OK_200;

// Handle URIs
HttpURI uri = HttpURI.from("https://example.com/api/users?id=123");
String host = uri.getHost(); // "example.com"
String path = uri.getPath(); // "/api/users"
String query = uri.getQuery(); // "id=123"

// Parse cookies
MutableHttpFields cookieHeaders = new MutableHttpFields();
cookieHeaders.add(HttpHeader.COOKIE, "session=abc123; user=john");
CookieCutter parser = new CookieCutter();
parser.parseFields(cookieHeaders);

Architecture

Jetty HTTP is organized around several key components:

  • Core HTTP Processing: HTTP methods, status codes, headers, and protocol handling (HttpMethod, HttpStatus, HttpField, HttpFields)
  • Parsing and Generation: HTTP message parsing and generation with compliance validation (HttpParser, HttpGenerator)
  • URI Handling: Comprehensive URI parsing, validation, and manipulation (HttpURI, UriCompliance)
  • Content Management: HTTP content handling with caching, compression, and virtual file systems (HttpContent, HttpContent.Factory)
  • Path Mapping: Flexible path specification matching for routing and dispatch (PathSpec, ServletPathSpec, PathMappings)
  • Compression: HPACK compression utilities for HTTP/2 header compression (NBitIntegerEncoder, Huffman)
  • Compliance: Configurable HTTP, URI, and cookie compliance modes with violation tracking

Capabilities

HTTP Headers and Fields

Core HTTP header handling with optimized field collections, type-safe header enums, and efficient header value processing.

// Header field creation and manipulation
HttpField field = new HttpField(HttpHeader.CONTENT_TYPE, "application/json");
MutableHttpFields fields = new MutableHttpFields();
HttpField result = fields.put(HttpHeader.CACHE_CONTROL, "no-cache");

// Header collections interface
interface HttpFields extends Iterable<HttpField> {
    int size();
    HttpField getField(String name);
    String get(HttpHeader header);
    boolean contains(String name, String value);
    Stream<HttpField> stream();
}

HTTP Headers and Fields

HTTP Methods and Status

Standard HTTP method and status code handling with safety and idempotency checks, efficient parsing, and caching.

// HTTP methods enumeration
enum HttpMethod {
    GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE, PATCH, CONNECT;
    
    boolean isSafe();
    boolean isIdempotent();
    ByteBuffer asBuffer();
    static HttpMethod fromString(String method);
}

// HTTP status codes and utilities
class HttpStatus {
    static final int OK_200 = 200;
    static final int NOT_FOUND_404 = 404;
    static final int INTERNAL_SERVER_ERROR_500 = 500;
    
    static String getMessage(int code);
    static boolean isInformational(int code);
    static boolean hasNoBody(int status);
}

HTTP Methods and Status

URI Processing

Comprehensive URI parsing, validation, and manipulation with compliance checking and efficient immutable/mutable patterns.

// URI interface and factories
interface HttpURI {
    String getScheme();
    String getHost();
    int getPort();
    String getPath();
    String getQuery();
    boolean isAbsolute();
    
    static HttpURI.Immutable from(String uri);
    static HttpURI.Mutable build(String uri);
}

// URI compliance validation
class UriCompliance {
    static final UriCompliance DEFAULT;
    static final UriCompliance LEGACY;
    boolean allows(Violation violation);
}

URI Processing

HTTP Parsing and Generation

High-performance HTTP message parsing and generation with configurable compliance modes and efficient buffer management.

// HTTP parsing
class HttpParser {
    HttpParser(RequestHandler requestHandler);
    HttpParser(ResponseHandler responseHandler);
    boolean parseNext(ByteBuffer buffer);
    boolean isComplete();
    void reset();
}

// HTTP generation
class HttpGenerator {
    Result generateResponse(MetaData.Response info, boolean head, 
                          ByteBuffer header, ByteBuffer chunk, 
                          ByteBuffer content, boolean last);
    boolean isEnd();
    void reset();
}

HTTP Parsing and Generation

Cookie Handling

Complete cookie parsing and management with RFC compliance support and attribute handling.

// Cookie interface
interface HttpCookie {
    String getName();
    String getValue();
    String getDomain();
    String getPath();
    boolean isSecure();
    boolean isHttpOnly();
    SameSite getSameSite();
    
    static HttpCookie from(String name, String value);
}

// Cookie parsing
interface CookieParser {
    void parseField(HttpField field);
    void parseFields(HttpFields fields);
}

Cookie Handling

Multi-Part Processing

Multi-part content handling for form data, file uploads, and byte ranges with async processing support.

// Multi-part content processing
class MultiPart {
    String getBoundary();
    List<Part> getParts();
    Part getPart(String name);
    
    interface Part {
        String getName();
        String getFileName();
        HttpFields getHeaders();
        Content.Source getContentSource();
    }
}

// Form data processing
class MultiPartFormData {
    CompletableFuture<Parts> parse(Content.Source source);
    Parts from(Content.Source source);
}

Multi-Part Processing

Content Management

HTTP content handling with factory patterns, caching, compression support, and virtual file systems.

// Content interface
interface HttpContent {
    HttpField getContentType();
    HttpField getContentLength();
    HttpField getLastModified();
    HttpField getETag();
    ByteBuffer getByteBuffer();
    void release();
    
    interface Factory {
        HttpContent getContent(String path);
    }
}

// Content factories
class ResourceHttpContentFactory implements HttpContent.Factory;
class CachingHttpContentFactory implements HttpContent.Factory;
class VirtualHttpContentFactory implements HttpContent.Factory;

Content Management

Path Mapping

Flexible path specification matching for routing and dispatch with support for servlet-style, regex, and URI template patterns.

// Path specification interface
interface PathSpec extends Comparable<PathSpec> {
    String getDeclaration();
    boolean matches(String path);
    MatchedPath matched(String path);
    String getPathInfo(String path);
}

// Path mappings collection
class PathMappings<E> extends AbstractMap<PathSpec, E> {
    MappedResource<E> getMatched(String path);
    List<MappedResource<E>> getMatches(String path);
    boolean put(PathSpec pathSpec, E resource);
}

// Servlet-style path specifications
class ServletPathSpec extends AbstractPathSpec {
    ServletPathSpec(String servletPathSpec);
}

Path Mapping

Compression Utilities

HPACK compression utilities for HTTP/2 header compression including N-bit integer encoding and Huffman coding.

// N-bit integer encoding/decoding
class NBitIntegerEncoder {
    static int octetsNeeded(int prefix, long value);
    static void encode(ByteBuffer buffer, int prefix, long value);
}

class NBitIntegerDecoder {
    void setPrefix(int prefix);
    int decodeInt(ByteBuffer buffer);
    long decodeLong(ByteBuffer buffer);
    void reset();
}

// Huffman coding
class Huffman {
    // Huffman encoding/decoding utilities
}

Compression Utilities

Common Types

// HTTP version enumeration
enum HttpVersion {
    HTTP_0_9, HTTP_1_0, HTTP_1_1, HTTP_2_0, HTTP_3_0;
    String asString();
    int getVersion();
}

// HTTP scheme enumeration  
enum HttpScheme {
    HTTP, HTTPS, WS, WSS;
    String asString();
    int getDefaultPort();
}

// Metadata for requests and responses
class MetaData implements Iterable<HttpField> {
    HttpURI getHttpURI();
    HttpVersion getHttpVersion();
    HttpFields getHttpFields();
    
    static class Request extends MetaData;
    static class Response extends MetaData;
}

// Compliance violation handling
interface ComplianceViolation {
    interface Listener {
        void onComplianceViolation(Mode mode, ComplianceViolation violation, String details);
    }
    
    enum Mode { COMPLIANCE, LEGACY, CUSTOM }
}

// Content processing interface
interface Content {
    interface Source {
        // Content source for streaming processing
    }
    
    interface Chunk {
        ByteBuffer getByteBuffer();
        boolean isLast();
    }
}

// Exception types
class BadMessageException extends HttpException.RuntimeException;
class ComplianceViolationException extends IllegalArgumentException;
class EncodingException extends Exception;