public final class HttpSupport extends Object
Using this example. Provides bounded form input and consistent resource, JSON and attachment responses for app routes. Financial calculations belong in the app services; this class only handles transport and response formatting.
| Constructor and Description |
|---|
HttpSupport() |
| Modifier and Type | Method and Description |
|---|---|
static void |
attachment(com.sun.net.httpserver.HttpExchange e,
String name,
String type,
byte[] body)
Callers supply generated safe names (report IDs and fixed format names).
|
static String |
error(String message) |
static Map<String,String> |
form(String body) |
static String |
readLimited(InputStream in) |
static void |
redirect(com.sun.net.httpserver.HttpExchange e,
String target) |
static Map<String,String> |
requestForm(com.sun.net.httpserver.HttpExchange e)
Both tools accept the same bounded form encoding.
|
static String |
required(Map<String,String> f,
String k) |
static boolean |
requireMethod(com.sun.net.httpserver.HttpExchange e,
String method)
Reject incorrect methods before reading a request body.
|
static void |
resource(com.sun.net.httpserver.HttpExchange e,
String file)
Serve a route-selected classpath resource; never accept an unchecked request path here.
|
static void |
respond(com.sun.net.httpserver.HttpExchange e,
int code,
String type,
byte[] bytes) |
static void |
send(com.sun.net.httpserver.HttpExchange e,
int code,
String body) |
public static String readLimited(InputStream in) throws IOException
IOExceptionpublic static Map<String,String> form(String body) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic static void send(com.sun.net.httpserver.HttpExchange e,
int code,
String body)
throws IOException
IOExceptionpublic static void respond(com.sun.net.httpserver.HttpExchange e,
int code,
String type,
byte[] bytes)
throws IOException
IOExceptionpublic static boolean requireMethod(com.sun.net.httpserver.HttpExchange e,
String method)
throws IOException
IOExceptionpublic static Map<String,String> requestForm(com.sun.net.httpserver.HttpExchange e) throws IOException
IOExceptionpublic static void redirect(com.sun.net.httpserver.HttpExchange e,
String target)
throws IOException
IOExceptionpublic static void resource(com.sun.net.httpserver.HttpExchange e,
String file)
throws IOException
IOExceptionpublic static void attachment(com.sun.net.httpserver.HttpExchange e,
String name,
String type,
byte[] body)
throws IOException
IOExceptionCopyright © 2026. All rights reserved.