本文整理了Java中org.simpleframework.http.Address
类的一些代码示例,展示了Address
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address
类的具体详情如下:
包路径:org.simpleframework.http.Address
类名称:Address
[英]The Address
interface is used to represent a generic uniform resource identifier. This interface allows each section of the uniform resource identifier to be represented. A generic uniform resource identifier syntax is represented in RFC 2616 section 3.2.2 for the HTTP protocol, this allows similar URI's for example ftp, http, https, tftp. The syntax is <<$0$>>
This interface represents the host, port, path and query part of the uniform resource identifier. The parameters are also represented by the URI. The parameters in a URI consist of name and value pairs in the path segment of the URI.
This will normalize the path part of the uniform resource identifier. A normalized path is one that contains no back references like "./" and "../". The normalized path will not contain the path parameters.
[中]Address
接口用于表示通用统一资源标识符。此接口允许表示统一资源标识符的每个部分。RFC 2616第3.2.2节中表示了HTTP协议的通用统一资源标识符语法,这允许类似的URI,例如ftp、HTTP、https、tftp。语法为<<$0$>>
此接口表示统一资源标识符的主机、端口、路径和查询部分。参数也由URI表示。URI中的参数由URI路径段中的名称和值对组成。
这将规范化统一资源标识符的路径部分。规范化路径是不包含像“/”和“./”这样的反向引用的路径。规范化路径将不包含路径参数。
代码示例来源:origin: jersey/jersey
private URI getBaseUri(final Request request) {
try {
final String hostHeader = request.getValue("Host");
if (hostHeader != null) {
final String scheme = request.isSecure() ? "https" : "http";
return new URI(scheme + "://" + hostHeader + "/");
} else {
final Address address = request.getAddress();
return new URI(address.getScheme(), null, address.getDomain(), address.getPort(), "/", null,
null);
}
} catch (final URISyntaxException ex) {
throw new IllegalArgumentException(ex);
}
}
代码示例来源:origin: mpetazzoni/ttorrent
myRequestProcessor.process(request.getAddress().toString(), request.getClientAddress().getAddress().getHostAddress(),
getRequestHandler(response));
} else {
myMultiAnnounceRequestProcessor.process(request.getContent(), request.getAddress().toString(),
request.getClientAddress().getAddress().getHostAddress(), getRequestHandler(response));
代码示例来源:origin: miltonio/milton2
Address a = baseRequest.getAddress();
if (host == null) {
host = a.getDomain();
if (a.getPort() != 80 && a.getPort() > 0) {
s = s + ":" + a.getPort();
代码示例来源:origin: org.simpleframework/simple-http
/**
* This is used to acquire the path as extracted from the
* the HTTP request URI. The <code>Path</code> object that is
* provided by this method is immutable, it represents the
* normalized path only part from the request URI.
*
* @return this returns the normalized path for the request
*/
public Path getPath() {
return getAddress().getPath();
}
代码示例来源:origin: org.simpleframework/simple
/**
* This method is used to acquire the query part from the
* HTTP request URI target. This will return only the values
* that have been extracted from the request URI target.
*
* @return the query associated with the HTTP target URI
*/
public Query getQuery() {
return getAddress().getQuery();
}
代码示例来源:origin: kristofa/mock-http-server
public static FullHttpRequest convert(final Request request) {
byte[] data = null;
try {
final InputStream inputStream = request.getInputStream();
try {
data = IOUtils.toByteArray(inputStream);
} finally {
inputStream.close();
}
} catch (final IOException e) {
LOGGER.error("IOException when getting request content.", e);
}
final FullHttpRequestImpl httpRequest = new FullHttpRequestImpl();
httpRequest.domain(request.getAddress().getDomain());
httpRequest.port(request.getAddress().getPort());
httpRequest.method(Method.valueOf(request.getMethod()));
httpRequest.path(request.getPath().getPath());
if (data.length > 0) {
httpRequest.content(data);
}
for (final String headerField : request.getNames()) {
for (final String headerFieldValue : request.getValues(headerField)) {
httpRequest.httpMessageHeader(headerField, headerFieldValue);
}
}
for (final Entry<String, String> entry : request.getQuery().entrySet()) {
httpRequest.queryParameter(entry.getKey(), entry.getValue());
}
return httpRequest;
}
代码示例来源:origin: org.simpleframework/simple
/**
* This is used to acquire the path as extracted from the
* the HTTP request URI. The <code>Path</code> object that is
* provided by this method is immutable, it represents the
* normalized path only part from the request URI.
*
* @return this returns the normalized path for the request
*/
public Path getPath() {
return getAddress().getPath();
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This method is used to acquire the query part from the
* HTTP request URI target. This will return only the values
* that have been extracted from the request URI target.
*
* @return the query associated with the HTTP target URI
*/
public Query getQuery() {
return getAddress().getQuery();
}
代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server
private URI getBaseUri(Request request) {
try {
final Address address = request.getAddress();
return new URI(
address.getScheme(),
null,
address.getDomain(),
address.getPort(),
"/",
null, null);
} catch (URISyntaxException ex) {
throw new IllegalArgumentException(ex);
}
}
代码示例来源:origin: miltonio/milton2
@Override
public String getFromAddress() {
Address add = baseRequest.getAddress();
if (add == null) {
return null;
}
return add.toString();
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This is used to acquire the path as extracted from the
* the HTTP request URI. The <code>Path</code> object that is
* provided by this method is immutable, it represents the
* normalized path only part from the request URI.
*
* @return this returns the normalized path for the request
*/
public Path getPath() {
return getAddress().getPath();
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* This method is used to acquire the query part from the
* HTTP request URI target. This will return only the values
* that have been extracted from the request URI target.
*
* @return the query associated with the HTTP target URI
*/
public Query getQuery() {
return getAddress().getQuery();
}
代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-simple-http
private URI getBaseUri(final Request request) {
try {
final String hostHeader = request.getValue("Host");
if (hostHeader != null) {
final String scheme = request.isSecure() ? "https" : "http";
return new URI(scheme + "://" + hostHeader + "/");
} else {
final Address address = request.getAddress();
return new URI(address.getScheme(), null, address.getDomain(), address.getPort(), "/", null,
null);
}
} catch (final URISyntaxException ex) {
throw new IllegalArgumentException(ex);
}
}
代码示例来源:origin: miltonio/milton2
@Override
public String toString() {
return request.getMethod() + " " + request.getAddress().toString();
}
代码示例来源:origin: zanata/zanata-platform
@Override
public void handle(Request request, Response response) {
try {
PrintStream body = response.getPrintStream();
long time = System.currentTimeMillis();
response.setValue("Content-Type", "text/plain");
response.setContentType("application/xml;charset=utf-8");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
String path = request.getAddress().getPath().getPath();
log.trace("request path is {}", path);
StatusAndContent statusAndContent = tryMatchPath(path);
Status status = statusAndContent.status;
response.setStatus(status);
String content = statusAndContent.content;
log.trace("mock container returning: status [{}], content [{}]",
status, content);
body.println(content);
body.close();
} catch (Exception e) {
e.printStackTrace();
response.setStatus(Status.INTERNAL_SERVER_ERROR);
try {
response.close();
} catch (IOException e1) {
throw new RuntimeException(e1);
}
}
}
代码示例来源:origin: org.kie.remote/kie-remote-client
public void handle( Request req, Response resp ) {
try {
PrintStream out = resp.getPrintStream(1024);
String address = req.getAddress().toString();
if( address.equals(DEFAULT_ENPOINT) ) {
String content = readInputStreamAsString(req.getInputStream());
JaxbCommandsRequest cmdsReq = (JaxbCommandsRequest) jaxbSerializationProvider.deserialize(content);
String [] headerNames = {
TEST_HEADER_NAME,
ANOTHER_TEST_HEADER_NAME,
NOT_SENT_HEADER_NAME
};
List<String> headerValues = new ArrayList<String>();
for( String headerName : headerNames ) {
String headerVal = req.getValue(headerName);
if( headerVal != null ) {
headerValues.add(headerVal);
}
}
String output = handleJaxbCommandsRequest(cmdsReq, headerValues);
resp.setCode(HttpURLConnection.HTTP_OK);
out.print(output);
} else {
resp.setCode(HttpURLConnection.HTTP_BAD_REQUEST);
}
out.close();
} catch( Exception e ) {
e.printStackTrace();
}
}
代码示例来源:origin: org.kie.remote/kie-remote-client
logger.debug(headers[0] + ": " + user + "/" + pass);
String address = req.getAddress().toString();
if( address.equals(DEFAULT_ENDPOINT) ) {
resp.setValue(HttpHeaders.CONTENT_TYPE, "text/plain");
代码示例来源:origin: org.kie.remote/kie-remote-client
public void handle( Request req, Response resp ) {
try {
PrintStream out = resp.getPrintStream(1024);
String address = req.getAddress().toString();
if( address.equals(REDIRECT_PATH) ) {
resp.setValue(HttpHeaders.LOCATION, REAL_ENDPOINT_PATH);
内容来源于网络,如有侵权,请联系作者删除!