本文整理了Java中org.apache.http.ProtocolException.<init>()
方法的一些代码示例,展示了ProtocolException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProtocolException.<init>()
方法的具体详情如下:
包路径:org.apache.http.ProtocolException
类名称:ProtocolException
方法名:<init>
[英]Creates a new ProtocolException with a null detail message.
[中]创建带有空详细信息的新ProtocolException。
代码示例来源:origin: robovm/robovm
if (HTTP.CHUNK_CODING.equalsIgnoreCase(s)) {
if (message.getProtocolVersion().lessEquals(HttpVersion.HTTP_1_0)) {
throw new ProtocolException(
"Chunked transfer encoding not allowed for " +
message.getProtocolVersion());
return IDENTITY;
} else {
throw new ProtocolException(
"Unsupported transfer encoding: " + s);
return len;
} catch (NumberFormatException e) {
throw new ProtocolException("Invalid content length: " + s);
代码示例来源:origin: robovm/robovm
encodings = transferEncodingHeader.getElements();
} catch (ParseException px) {
throw new ProtocolException
("Invalid Transfer-Encoding header value: " +
transferEncodingHeader, px);
&& !encoding.equalsIgnoreCase(HTTP.CHUNK_CODING)
&& !encoding.equalsIgnoreCase(HTTP.IDENTITY_CODING)) {
throw new ProtocolException("Unsupported transfer encoding: " + encoding);
} else {
if (strict) {
throw new ProtocolException("Chunk-encoding must be the last one applied");
Header[] headers = message.getHeaders(HTTP.CONTENT_LEN);
if (strict && headers.length > 1) {
throw new ProtocolException("Multiple content length headers");
} catch (NumberFormatException e) {
if (strict) {
throw new ProtocolException("Invalid content length: " + header.getValue());
代码示例来源:origin: robovm/robovm
if (locationHeader == null) {
throw new ProtocolException(
"Received redirect response " + response.getStatusLine()
+ " but no location header");
uri = new URI(location);
} catch (URISyntaxException ex) {
throw new ProtocolException("Invalid redirect URI: " + location, ex);
throw new ProtocolException("Relative redirect location '"
+ uri + "' not allowed");
uri = URIUtils.resolve(absoluteRequestURI, uri);
} catch (URISyntaxException ex) {
throw new ProtocolException(ex.getMessage(), ex);
redirectURI = URIUtils.rewriteURI(uri, target, true);
} catch (URISyntaxException ex) {
throw new ProtocolException(ex.getMessage(), ex);
代码示例来源:origin: robovm/robovm
return;
} else {
throw new ProtocolException("Target host missing");
代码示例来源:origin: robovm/robovm
public RequestWrapper(final HttpRequest request) throws ProtocolException {
super();
if (request == null) {
throw new IllegalArgumentException("HTTP request may not be null");
}
this.original = request;
setParams(request.getParams());
// Make a copy of the original URI
if (request instanceof HttpUriRequest) {
this.uri = ((HttpUriRequest) request).getURI();
this.method = ((HttpUriRequest) request).getMethod();
this.version = null;
} else {
RequestLine requestLine = request.getRequestLine();
try {
this.uri = new URI(requestLine.getUri());
} catch (URISyntaxException ex) {
throw new ProtocolException("Invalid request URI: "
+ requestLine.getUri(), ex);
}
this.method = requestLine.getMethod();
this.version = request.getProtocolVersion();
}
this.execCount = 0;
}
代码示例来源:origin: robovm/robovm
public HttpMessage parse() throws IOException, HttpException {
HttpMessage message = null;
try {
message = parseHead(this.sessionBuffer);
} catch (ParseException px) {
throw new ProtocolException(px.getMessage(), px);
}
Header[] headers = AbstractMessageParser.parseHeaders(
this.sessionBuffer,
this.maxHeaderCount,
this.maxLineLen,
this.lineParser);
message.setHeaders(headers);
return message;
}
代码示例来源:origin: robovm/robovm
throw new ProtocolException("Transfer-encoding header already present");
throw new ProtocolException("Content-Length header already present");
代码示例来源:origin: robovm/robovm
throw new ProtocolException("Transfer-encoding header already present");
throw new ProtocolException("Content-Length header already present");
throw new ProtocolException(
"Chunked transfer encoding not allowed for " + ver);
代码示例来源:origin: robovm/robovm
requestURI = new URI(request.getRequestLine().getUri());
} catch (URISyntaxException ex) {
throw new ProtocolException("Invalid request URI: " +
request.getRequestLine().getUri(), ex);
代码示例来源:origin: robolectric/robolectric
protected void rewriteRequestURI(
final RequestWrapper request,
final HttpRoute route) throws ProtocolException {
try {
URI uri = request.getURI();
if (route.getProxyHost() != null && !route.isTunnelled()) {
// Make sure the request URI is absolute
if (!uri.isAbsolute()) {
HttpHost target = route.getTargetHost();
uri = URIUtils.rewriteURI(uri, target);
request.setURI(uri);
}
} else {
// Make sure the request URI is relative
if (uri.isAbsolute()) {
uri = URIUtils.rewriteURI(uri, null);
request.setURI(uri);
}
}
} catch (URISyntaxException ex) {
throw new ProtocolException("Invalid URI: " +
request.getRequestLine().getUri(), ex);
}
}
代码示例来源:origin: robovm/robovm
protected void rewriteRequestURI(
final RequestWrapper request,
final HttpRoute route) throws ProtocolException {
try {
URI uri = request.getURI();
if (route.getProxyHost() != null && !route.isTunnelled()) {
// Make sure the request URI is absolute
if (!uri.isAbsolute()) {
HttpHost target = route.getTargetHost();
uri = URIUtils.rewriteURI(uri, target);
request.setURI(uri);
}
} else {
// Make sure the request URI is relative
if (uri.isAbsolute()) {
uri = URIUtils.rewriteURI(uri, null);
request.setURI(uri);
}
}
} catch (URISyntaxException ex) {
throw new ProtocolException("Invalid URI: " +
request.getRequestLine().getUri(), ex);
}
}
代码示例来源:origin: robovm/robovm
headers[i] = parser.parseHeader(buffer);
} catch (ParseException ex) {
throw new ProtocolException(ex.getMessage());
代码示例来源:origin: robovm/robovm
@Override
protected HttpMessage parseHead(
final SessionInputBuffer sessionBuffer) throws IOException, HttpException {
// clear the buffer
this.lineBuf.clear();
//read out the HTTP status string
int count = 0;
ParserCursor cursor = null;
do {
int i = sessionBuffer.readLine(this.lineBuf);
if (i == -1 && count == 0) {
// The server just dropped connection on us
throw new NoHttpResponseException("The target server failed to respond");
}
cursor = new ParserCursor(0, this.lineBuf.length());
if (lineParser.hasProtocolVersion(this.lineBuf, cursor)) {
// Got one
break;
} else if (i == -1 || count >= this.maxGarbageLines) {
// Giving up
throw new ProtocolException("The server failed to respond with a " +
"valid HTTP response");
}
count++;
} while(true);
//create the status line from the status string
StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor);
return this.responseFactory.newHttpResponse(statusline, null);
}
代码示例来源:origin: ibinti/bugvm
@Override
public long determineLength(final HttpMessage message) throws HttpException {
final long result = this.contentLengthStrategy.determineLength(message);
if (result == ContentLengthStrategy.IDENTITY) {
throw new ProtocolException("Identity transfer encoding cannot be used");
}
return result;
}
代码示例来源:origin: org.apache.httpcomponents/httpclient-android
public long determineLength(final HttpMessage message) throws HttpException {
final long result = this.contentLengthStrategy.determineLength(message);
if (result == ContentLengthStrategy.IDENTITY) {
throw new ProtocolException("Identity transfer encoding cannot be used");
}
return result;
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpcore
public long determineLength(final HttpMessage message) throws HttpException {
final long result = this.contentLengthStrategy.determineLength(message);
if (result == ContentLengthStrategy.IDENTITY) {
throw new ProtocolException("Identity transfer encoding cannot be used");
}
return result;
}
代码示例来源:origin: com.hubspot/HorizonApache
@Override
protected URI createLocationURI(String location) throws ProtocolException {
try {
return new URI(location).normalize();
} catch (URISyntaxException e) {
try {
return parseLenient(location).normalize();
} catch (URISyntaxException f) {
throw new ProtocolException("Invalid redirect URI: " + location, e);
}
}
}
代码示例来源:origin: com.hynnet/httpclient
void rewriteRequestURI(
final HttpRequestWrapper request,
final HttpRoute route) throws ProtocolException {
final URI uri = request.getURI();
if (uri != null) {
try {
request.setURI(URIUtils.rewriteURIForRoute(uri, route));
} catch (final URISyntaxException ex) {
throw new ProtocolException("Invalid URI: " + uri, ex);
}
}
}
代码示例来源:origin: ibinti/bugvm
void rewriteRequestURI(
final HttpRequestWrapper request,
final HttpRoute route) throws ProtocolException {
final URI uri = request.getURI();
if (uri != null) {
try {
request.setURI(URIUtils.rewriteURIForRoute(uri, route));
} catch (final URISyntaxException ex) {
throw new ProtocolException("Invalid URI: " + uri, ex);
}
}
}
代码示例来源:origin: com.bugvm/bugvm-rt
void rewriteRequestURI(
final HttpRequestWrapper request,
final HttpRoute route) throws ProtocolException {
final URI uri = request.getURI();
if (uri != null) {
try {
request.setURI(URIUtils.rewriteURIForRoute(uri, route));
} catch (final URISyntaxException ex) {
throw new ProtocolException("Invalid URI: " + uri, ex);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!