Package org.basex.http
Class HTTPConnection
java.lang.Object
org.basex.http.HTTPConnection
- All Implemented Interfaces:
ClientInfo
Single HTTP connection.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ContextCurrent database context.Request method.final javax.servlet.http.HttpServletRequestHTTP servlet request.final RequestContextRequest parameters.final javax.servlet.http.HttpServletResponseHTTP servlet response. -
Method Summary
Modifier and TypeMethodDescriptionaccepts()Returns all accepted media types.voidauthenticate(String username) Authorizes a request.db()Returns the addressed database (i.e., the first path entry).dbpath()Returns the database path (i.e., all path entries except for the first).voidHandles an error with an info message.voidSends a forward.voidInitializes the output and assigns the character encoding and content type.voidWrites a log message.Returns the content type of a request as media type.static MediaTypemediaType(javax.servlet.http.HttpServletRequest request) Returns the content type of a request as media type.static MediaTypemediaType(SerializerOptions sopts) Returns the media type defined in the specified serialization parameters.path()Returns the URL path.voidSends a redirect.static StringremoteAddress(javax.servlet.http.HttpServletRequest request) Returns the content type of a request, or an empty string.Normalizes a redirection location.sopts()Returns the serialization parameters.voidsopts(SerializerOptions opts) Assigns serialization parameters.voidSets a status and sends an info message.voidstop(JobException ex) Sets 460 a proprietary status code and sends the exception message as info.voidSets profiling information.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.basex.server.ClientInfo
clientName
-
Field Details
-
request
public final javax.servlet.http.HttpServletRequest requestHTTP servlet request. -
response
public final javax.servlet.http.HttpServletResponse responseHTTP servlet response. -
context
Current database context. -
requestCtx
Request parameters. -
method
Request method.
-
-
Method Details
-
authenticate
Authorizes a request. Initializes the user if it is called for the first time.- Parameters:
username- name of default servlet user (can benull)- Throws:
IOException- I/O exception
-
mediaType
Returns the content type of a request as media type.- Returns:
- content type
-
initResponse
public void initResponse()Initializes the output and assigns the character encoding and content type. -
path
Returns the URL path. The path always starts with a slash.- Returns:
- path path
-
dbpath
Returns the database path (i.e., all path entries except for the first).- Returns:
- database path
-
db
Returns the addressed database (i.e., the first path entry).- Returns:
- database, or
nullif the root directory was specified
-
accepts
Returns all accepted media types.- Returns:
- accepted media types
-
error
Handles an error with an info message.- Parameters:
code- status codeinfo- info, will additionally be logged- Throws:
IOException- I/O exception
-
sopts
Assigns serialization parameters.- Parameters:
opts- serialization parameters
-
sopts
Returns the serialization parameters.- Returns:
- serialization parameters
-
log
Writes a log message.- Parameters:
status- HTTP status codeinfo- info string (can benull)
-
resolve
Normalizes a redirection location. Prefixes absolute locations with the request URI.- Parameters:
location- location- Returns:
- normalized representation
-
redirect
Sends a redirect.- Parameters:
location- location- Throws:
IOException- I/O exception
-
forward
Sends a forward.- Parameters:
location- location- Throws:
IOException- I/O exceptionjavax.servlet.ServletException- servlet exception
-
clientAddress
- Specified by:
clientAddressin interfaceClientInfo
-
clientName
- Specified by:
clientNamein interfaceClientInfo
-
stop
Sets 460 a proprietary status code and sends the exception message as info.- Parameters:
ex- job exception- Throws:
IOException- I/O exception
-
status
Sets a status and sends an info message.- Parameters:
code- status codemessage- status message (can benull)body- message for response body (can benull)- Throws:
IOException- I/O exception
-
timing
Sets profiling information.- Parameters:
qi- query info
-
mediaType
Returns the media type defined in the specified serialization parameters.- Parameters:
sopts- serialization parameters- Returns:
- media type
-
mediaType
Returns the content type of a request as media type.- Parameters:
request- servlet request- Returns:
- content type
-
remoteAddress
Returns the content type of a request, or an empty string.- Parameters:
request- servlet request- Returns:
- content type
-