Merge pull request #5202 from joefarebrother/apache-http

Java: Add modelling for Apache HTTP Components
This commit is contained in:
Anders Schack-Mulligen
2021-03-03 13:41:41 +01:00
committed by GitHub
58 changed files with 3383 additions and 30 deletions

View File

@@ -0,0 +1,2 @@
lgtm,codescanning
* Added support for the Apache Http components core library (`org.apache.http.*` and `org.apache.hc.core5.*`); adding additional remote flow sources, sinks for the XSS and Open Redirect queries, and additional taint steps.

View File

@@ -64,6 +64,14 @@ import java
private import semmle.code.java.dataflow.DataFlow::DataFlow
private import internal.DataFlowPrivate
/**
* A module importing the frameworks that provide external flow data,
* ensuring that they are visible to the taint tracking / data flow library.
*/
private module Frameworks {
private import semmle.code.java.frameworks.ApacheHttp
}
private predicate sourceModelCsv(string row) {
row =
[
@@ -214,7 +222,7 @@ module CsvValidation {
not name.regexpMatch("[a-zA-Z0-9_]*") and
msg = "Dubious name \"" + name + "\" in " + pred + " model."
or
not signature.regexpMatch("|\\([a-zA-Z0-9_\\.\\$<>,]*\\)") and
not signature.regexpMatch("|\\([a-zA-Z0-9_\\.\\$<>,\\[\\]]*\\)") and
msg = "Dubious signature \"" + signature + "\" in " + pred + " model."
or
not ext.regexpMatch("|Annotated") and

View File

@@ -9,7 +9,7 @@ private import semmle.code.java.dataflow.DataFlow
* A module importing the frameworks that implement additional flow steps,
* ensuring that they are visible to the taint tracking library.
*/
module Frameworks {
private module Frameworks {
private import semmle.code.java.frameworks.jackson.JacksonSerializability
private import semmle.code.java.frameworks.android.Intent
private import semmle.code.java.frameworks.android.SQLite
@@ -17,6 +17,7 @@ module Frameworks {
private import semmle.code.java.frameworks.Protobuf
private import semmle.code.java.frameworks.guava.Guava
private import semmle.code.java.frameworks.apache.Lang
private import semmle.code.java.frameworks.ApacheHttp
}
/**

View File

@@ -1,8 +1,10 @@
/**
* Provides classes and predicates related to `org.apache.http.*`.
* Provides classes and predicates related to `org.apache.http.*` and `org.apache.hc.*`.
*/
import java
private import semmle.code.java.dataflow.FlowSteps
private import semmle.code.java.dataflow.ExternalFlow
class ApacheHttpGetParams extends Method {
ApacheHttpGetParams() {
@@ -39,3 +41,192 @@ class TypeApacheHttpRequestBuilder extends Class {
this.hasQualifiedName("org.apache.http.client.methods", "RequestBuilder")
}
}
private class ApacheHttpSource extends SourceModelCsv {
override predicate row(string row) {
row =
[
"org.apache.http.protocol;HttpRequestHandler;true;handle;(HttpRequest,HttpResponse,HttpContext);;Parameter[0];remote",
"org.apache.hc.core5.http.io;HttpRequestHandler;true;handle;(ClassicHttpRequest,ClassicHttpResponse,HttpContext);;Parameter[0];remote",
"org.apache.hc.core5.http.io;HttpServerRequestHandler;true;handle;(ClassicHttpRequest,ResponseTrigger,HttpContext);;Parameter[0];remote"
]
}
}
/**
* A call that sets a header of an `HttpResponse`.
*/
class ApacheHttpSetHeader extends Call {
ApacheHttpSetHeader() {
exists(Method m |
this.getCallee().(Method).overrides*(m) and
m.getDeclaringType()
.hasQualifiedName(["org.apache.http", "org.apache.hc.core5.http"], "HttpMessage") and
m.hasName(["addHeader", "setHeader"]) and
m.getNumberOfParameters() = 2
)
or
exists(Constructor c |
this.getCallee() = c and
c.getDeclaringType()
.hasQualifiedName(["org.apache.http.message", "org.apache.hc.core5.http.message"],
"BasicHeader")
)
}
/** Gets the expression used as the name of this header. */
Expr getName() { result = this.getArgument(0) }
/** Gets the expression used as the value of this header. */
Expr getValue() { result = this.getArgument(1) }
}
private class ApacheHttpXssSink extends SinkModelCsv {
override predicate row(string row) {
row =
[
"org.apache.http;HttpResponse;true;setEntity;(HttpEntity);;Argument[0];xss",
"org.apache.http.util;EntityUtils;true;updateEntity;(HttpResponse,HttpEntity);;Argument[1];xss",
"org.apache.hc.core5.http;HttpEntityContainer;true;setEntity;(HttpEntity);;Argument[0];xss"
]
}
}
private class ApacheHttpFlowStep extends SummaryModelCsv {
override predicate row(string row) {
row =
[
"org.apache.http;HttpMessage;true;getAllHeaders;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpMessage;true;getFirstHeader;(String);;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpMessage;true;getLastHeader;(String);;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpMessage;true;getHeaders;(String);;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpMessage;true;getParams;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpMessage;true;headerIterator;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpMessage;true;headerIterator;(String);;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpRequest;true;getRequestLine;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpEntityEnclosingRequest;true;getEntity;();;Argument[-1];ReturnValue;taint",
"org.apache.http;Header;true;getElements;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HeaderElement;true;getName;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HeaderElement;true;getValue;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HeaderElement;true;getParameter;(int);;Argument[-1];ReturnValue;taint",
"org.apache.http;HeaderElement;true;getParameterByName;(String);;Argument[-1];ReturnValue;taint",
"org.apache.http;HeaderElement;true;getParameters;();;Argument[-1];ReturnValue;taint",
"org.apache.http;NameValuePair;true;getName;();;Argument[-1];ReturnValue;taint",
"org.apache.http;NameValuePair;true;getValue;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HeaderIterator;true;nextHeader;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpEntity;true;getContent;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpEntity;true;getContentEncoding;();;Argument[-1];ReturnValue;taint",
"org.apache.http;HttpEntity;true;getContentType;();;Argument[-1];ReturnValue;taint",
"org.apache.http;RequestLine;true;getMethod;();;Argument[-1];ReturnValue;taint",
"org.apache.http;RequestLine;true;getUri;();;Argument[-1];ReturnValue;taint",
"org.apache.http.params;HttpParams;true;getParameter;(String);;Argument[-1];ReturnValue;taint",
"org.apache.http.params;HttpParams;true;getDoubleParameter;(String,double);;Argument[-1];ReturnValue;taint",
"org.apache.http.params;HttpParams;true;getIntParameter;(String,int);;Argument[-1];ReturnValue;taint",
"org.apache.http.params;HttpParams;true;getLongParameter;(String,long);;Argument[-1];ReturnValue;taint",
"org.apache.http.params;HttpParams;true;getDoubleParameter;(String,double);;Argument[1];ReturnValue;value",
"org.apache.http.params;HttpParams;true;getIntParameter;(String,int);;Argument[1];ReturnValue;value",
"org.apache.http.params;HttpParams;true;getLongParameter;(String,long);;Argument[1];ReturnValue;value",
"org.apache.hc.core5.http;MessageHeaders;true;getFirstHeader;(String);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;MessageHeaders;true;getLastHeader;(String);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;MessageHeaders;true;getHeader;(String);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;MessageHeaders;true;getHeaders;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;MessageHeaders;true;getHeaders;(String);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;MessageHeaders;true;headerIterator;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;MessageHeaders;true;headerIterator;(String);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpRequest;true;getAuthority;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpRequest;true;getMethod;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpRequest;true;getPath;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpRequest;true;getUri;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpRequest;true;getRequestUri;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpEntityContainer;true;getEntity;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;NameValuePair;true;getName;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;NameValuePair;true;getValue;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpEntity;true;getContent;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;HttpEntity;true;getTrailers;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;EntityDetails;true;getContentType;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;EntityDetails;true;getContentEncoding;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http;EntityDetails;true;getTrailerNames;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http.message;RequestLine;true;getMethod;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http.message;RequestLine;true;getUri;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http.message;RequestLine;true;toString;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.http.message;RequestLine;true;RequestLine;(HttpRequest);;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.message;RequestLine;true;RequestLine;(String,String,ProtocolVersion);;Argument[1];ReturnValue;taint",
"org.apache.hc.core5.http.message;RequestLine;true;RequestLine;(String,String,ProtocolVersion);;Argument[1];ReturnValue;taint",
"org.apache.hc.core5.function;Supplier;true;get;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.net;URIAuthority;true;getHostName;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.net;URIAuthority;true;toString;();;Argument[-1];ReturnValue;taint",
"org.apache.http.util;EntityUtils;true;toString;;;Argument[0];ReturnValue;taint",
"org.apache.http.util;EntityUtils;true;toByteArray;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.http.util;EntityUtils;true;getContentCharSet;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.http.util;EntityUtils;true;getContentMimeType;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;EntityUtils;true;toString;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;EntityUtils;true;toByteArray;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;EntityUtils;true;parse;;;Argument[0];ReturnValue;taint",
"org.apache.http.util;EncodingUtils;true;getAsciiBytes;(String);;Argument[0];ReturnValue;taint",
"org.apache.http.util;EncodingUtils;true;getAsciiString;;;Argument[0];ReturnValue;taint",
"org.apache.http.util;EncodingUtils;true;getBytes;(String,String);;Argument[0];ReturnValue;taint",
"org.apache.http.util;EncodingUtils;true;getString;;;Argument[0];ReturnValue;taint",
"org.apache.http.util;Args;true;containsNoBlanks;(T,String);;Argument[0];ReturnValue;value",
"org.apache.http.util;Args;true;notNull;(T,String);;Argument[0];ReturnValue;value",
"org.apache.http.util;Args;true;notEmpty;(T,String);;Argument[0];ReturnValue;value",
"org.apache.http.util;Args;true;notBlank;(T,String);;Argument[0];ReturnValue;value",
"org.apache.hc.core5.util;Args;true;containsNoBlanks;(T,String);;Argument[0];ReturnValue;value",
"org.apache.hc.core5.util;Args;true;notNull;(T,String);;Argument[0];ReturnValue;value",
"org.apache.hc.core5.util;Args;true;notEmpty;(T,String);;Argument[0];ReturnValue;value",
"org.apache.hc.core5.util;Args;true;notBlank;(T,String);;Argument[0];ReturnValue;value",
"org.apache.hc.core5.http.io.entity;HttpEntities;true;create;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;HttpEntities;true;createGzipped;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;HttpEntities;true;createUrlEncoded;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;HttpEntities;true;gzip;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;HttpEntities;true;withTrailers;;;Argument[0];ReturnValue;taint",
"org.apache.http.entity;BasicHttpEntity;true;setContent;(InputStream);;Argument[0];Argument[-1];taint",
"org.apache.http.entity;BufferedHttpEntity;true;BufferedHttpEntity;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.http.entity;ByteArrayEntity;true;ByteArrayEntity;;;Argument[0];ReturnValue;taint",
"org.apache.http.entity;HttpEntityWrapper;true;HttpEntityWrapper;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.http.entity;InputStreamEntity;true;InputStreamEntity;;;Argument[0];ReturnValue;taint",
"org.apache.http.entity;StringEntity;true;StringEntity;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;BasicHttpEntity;true;BasicHttpEntity;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;BufferedHttpEntity;true;BufferedHttpEntity;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;ByteArrayEntity;true;ByteArrayEntity;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;HttpEntityWrapper;true;HttpEntityWrapper;(HttpEntity);;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;InputStreamEntity;true;InputStreamEntity;;;Argument[0];ReturnValue;taint",
"org.apache.hc.core5.http.io.entity;StringEntity;true;StringEntity;;;Argument[0];ReturnValue;taint",
"org.apache.http.util;ByteArrayBuffer;true;append;(byte[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.http.util;ByteArrayBuffer;true;append;(char[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.http.util;ByteArrayBuffer;true;append;(CharArrayBuffer,int,int);;Argument[0];Argument[-1];taint",
"org.apache.http.util;ByteArrayBuffer;true;buffer;();;Argument[-1];ReturnValue;taint",
"org.apache.http.util;ByteArrayBuffer;true;toByteArray;();;Argument[-1];ReturnValue;taint",
"org.apache.http.util;CharArrayBuffer;true;append;(byte[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.http.util;CharArrayBuffer;true;append;(char[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.http.util;CharArrayBuffer;true;append;(CharArrayBuffer,int,int);;Argument[0];Argument[-1];taint",
"org.apache.http.util;CharArrayBuffer;true;append;(ByteArrayBuffer,int,int);;Argument[0];Argument[-1];taint",
"org.apache.http.util;CharArrayBuffer;true;append;(CharArrayBuffer);;Argument[0];Argument[-1];taint",
"org.apache.http.util;CharArrayBuffer;true;append;(String);;Argument[0];Argument[-1];taint",
"org.apache.http.util;CharArrayBuffer;true;append;(Object);;Argument[0];Argument[-1];taint",
"org.apache.http.util;CharArrayBuffer;true;buffer;();;Argument[-1];ReturnValue;taint",
"org.apache.http.util;CharArrayBuffer;true;toCharArray;();;Argument[-1];ReturnValue;taint",
"org.apache.http.util;CharArrayBuffer;true;toString;();;Argument[-1];ReturnValue;taint",
"org.apache.http.util;CharArrayBuffer;true;substring;(int,int);;Argument[-1];ReturnValue;taint",
"org.apache.http.util;CharArrayBuffer;true;subSequence;(int,int);;Argument[-1];ReturnValue;taint",
"org.apache.http.util;CharArrayBuffer;true;substringTrimmed;(int,int);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;ByteArrayBuffer;true;append;(byte[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;ByteArrayBuffer;true;append;(char[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;ByteArrayBuffer;true;append;(CharArrayBuffer,int,int);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;ByteArrayBuffer;true;array;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;ByteArrayBuffer;true;toByteArray;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;append;(byte[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;append;(char[],int,int);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;append;(CharArrayBuffer,int,int);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;append;(ByteArrayBuffer,int,int);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;append;(CharArrayBuffer);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;append;(String);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;append;(Object);;Argument[0];Argument[-1];taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;array;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;toCharArray;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;toString;();;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;substring;(int,int);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;subSequence;(int,int);;Argument[-1];ReturnValue;taint",
"org.apache.hc.core5.util;CharArrayBuffer;true;substringTrimmed;(int,int);;Argument[-1];ReturnValue;taint"
]
}
}

View File

@@ -3,6 +3,7 @@
import java
import semmle.code.java.dataflow.DataFlow
import semmle.code.java.frameworks.Servlets
import semmle.code.java.frameworks.ApacheHttp
/** A URL redirection sink */
abstract class UrlRedirectSink extends DataFlow::Node { }
@@ -24,3 +25,13 @@ private class ServletUrlRedirectSink extends UrlRedirectSink {
)
}
}
/** A URL redirection sink from Apache Http components. */
private class ApacheUrlRedirectSink extends UrlRedirectSink {
ApacheUrlRedirectSink() {
exists(ApacheHttpSetHeader c |
c.getName().(CompileTimeConstantExpr).getStringValue() = "Location" and
this.asExpr() = c.getValue()
)
}
}

View File

@@ -7,6 +7,7 @@ import semmle.code.java.frameworks.spring.SpringController
import semmle.code.java.frameworks.spring.SpringHttp
import semmle.code.java.dataflow.DataFlow
import semmle.code.java.dataflow.TaintTracking2
import semmle.code.java.dataflow.ExternalFlow
/** A sink that represent a method that outputs data without applying contextual output encoding. */
abstract class XssSink extends DataFlow::Node { }
@@ -31,6 +32,8 @@ class XssAdditionalTaintStep extends Unit {
/** A default sink representing methods susceptible to XSS attacks. */
private class DefaultXssSink extends XssSink {
DefaultXssSink() {
sinkNode(this, "xss")
or
exists(HttpServletResponseSendErrorMethod m, MethodAccess ma |
ma.getMethod() = m and
this.asExpr() = ma.getArgument(1)

View File

@@ -0,0 +1,65 @@
import org.apache.http.*;
import org.apache.http.protocol.*;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.*;
import org.apache.http.entity.*;
import java.io.IOException;
class A {
static Object taint() { return null; }
static void sink(Object o) { }
class Test1 implements HttpRequestHandler {
public void handle(HttpRequest req, HttpResponse res, HttpContext ctx) throws IOException {
A.sink(req.getRequestLine()); //$hasTaintFlow=y
A.sink(req.getRequestLine().getUri()); //$hasTaintFlow=y
A.sink(req.getRequestLine().getMethod()); //$hasTaintFlow=y
A.sink(req.getAllHeaders()); //$hasTaintFlow=y
HeaderIterator it = req.headerIterator();
A.sink(it.next()); //$hasTaintFlow=y
A.sink(it.nextHeader()); //$hasTaintFlow=y
Header h = req.getHeaders("abc")[3];
A.sink(h.getName()); //$hasTaintFlow=y
A.sink(h.getValue()); //$hasTaintFlow=y
HeaderElement el = h.getElements()[0];
A.sink(el.getName()); //$hasTaintFlow=y
A.sink(el.getValue()); //$hasTaintFlow=y
A.sink(el.getParameters()); //$hasTaintFlow=y
A.sink(el.getParameterByName("abc").getValue()); //$hasTaintFlow=y
A.sink(el.getParameter(0).getName()); //$hasTaintFlow=y
HttpEntity ent = ((HttpEntityEnclosingRequest)req).getEntity();
A.sink(ent.getContent()); //$hasTaintFlow=y
A.sink(ent.getContentEncoding()); //$hasTaintFlow=y
A.sink(ent.getContentType()); //$hasTaintFlow=y
A.sink(EntityUtils.toString(ent)); //$hasTaintFlow=y
A.sink(EntityUtils.toByteArray(ent)); //$hasTaintFlow=y
A.sink(EntityUtils.getContentCharSet(ent)); //$hasTaintFlow=y
A.sink(EntityUtils.getContentMimeType(ent)); //$hasTaintFlow=y
res.setEntity(new StringEntity("<a href='" + req.getRequestLine().getUri() + "'>a</a>")); //$hasTaintFlow=y
EntityUtils.updateEntity(res, new ByteArrayEntity(EntityUtils.toByteArray(ent))); //$hasTaintFlow=y
res.setHeader("Location", req.getRequestLine().getUri()); //$hasTaintFlow=y
res.setHeader(new BasicHeader("Location", req.getRequestLine().getUri())); //$hasTaintFlow=y
}
}
void test2() {
ByteArrayBuffer bbuf = new ByteArrayBuffer(42);
bbuf.append((byte[]) taint(), 0, 3);
sink(bbuf.buffer()); //$hasTaintFlow=y
sink(bbuf.toByteArray()); //$hasTaintFlow=y
CharArrayBuffer cbuf = new CharArrayBuffer(42);
cbuf.append(bbuf.toByteArray(), 0, 3);
sink(cbuf.toCharArray()); //$hasTaintFlow=y
sink(cbuf.toString()); //$hasTaintFlow=y
sink(cbuf.subSequence(0, 3)); //$hasTaintFlow=y
sink(cbuf.substring(0, 3)); //$hasTaintFlow=y
sink(cbuf.substringTrimmed(0, 3)); //$hasTaintFlow=y
sink(Args.notNull(taint(), "x")); //$hasTaintFlow=y
sink(Args.notEmpty((String) taint(), "x")); //$hasTaintFlow=y
sink(Args.notBlank((String) taint(), "x")); //$hasTaintFlow=y
sink(Args.notNull("x", (String) taint())); // Good
}
}

View File

@@ -0,0 +1,76 @@
import org.apache.hc.core5.http.*;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.io.HttpRequestHandler;
import org.apache.hc.core5.http.io.HttpServerRequestHandler;
import org.apache.hc.core5.http.message.*;
import org.apache.hc.core5.http.io.entity.*;
import org.apache.hc.core5.util.*;
import java.io.IOException;
class B {
static Object taint() { return null; }
static void sink(Object o) { }
class Test1 implements HttpRequestHandler {
public void handle(ClassicHttpRequest req, ClassicHttpResponse res, HttpContext ctx) throws IOException, ParseException {
B.sink(req.getAuthority().getHostName()); //$hasTaintFlow=y
B.sink(req.getAuthority().toString()); //$hasTaintFlow=y
B.sink(req.getMethod()); //$hasTaintFlow=y
B.sink(req.getPath()); //$hasTaintFlow=y
B.sink(req.getScheme());
B.sink(req.getRequestUri()); //$hasTaintFlow=y
RequestLine line = new RequestLine(req);
B.sink(line.getUri()); //$hasTaintFlow=y
B.sink(line.getMethod()); //$hasTaintFlow=y
B.sink(req.getHeaders()); //$hasTaintFlow=y
B.sink(req.headerIterator()); //$hasTaintFlow=y
Header h = req.getHeaders("abc")[3];
B.sink(h.getName()); //$hasTaintFlow=y
B.sink(h.getValue()); //$hasTaintFlow=y
B.sink(req.getFirstHeader("abc")); //$hasTaintFlow=y
B.sink(req.getLastHeader("abc")); //$hasTaintFlow=y
HttpEntity ent = req.getEntity();
B.sink(ent.getContent()); //$hasTaintFlow=y
B.sink(ent.getContentEncoding()); //$hasTaintFlow=y
B.sink(ent.getContentType()); //$hasTaintFlow=y
B.sink(ent.getTrailerNames()); //$hasTaintFlow=y
B.sink(ent.getTrailers().get()); //$hasTaintFlow=y
B.sink(EntityUtils.toString(ent)); //$hasTaintFlow=y
B.sink(EntityUtils.toByteArray(ent)); //$hasTaintFlow=y
B.sink(EntityUtils.parse(ent)); //$hasTaintFlow=y
res.setEntity(new StringEntity("<a href='" + req.getRequestUri() + "'>a</a>")); //$hasTaintFlow=y
res.setEntity(new ByteArrayEntity(EntityUtils.toByteArray(ent), ContentType.TEXT_HTML)); //$hasTaintFlow=y
res.setEntity(HttpEntities.create("<a href='" + req.getRequestUri() + "'>a</a>")); //$hasTaintFlow=y
res.setHeader("Location", req.getRequestUri()); //$hasTaintFlow=y
res.setHeader(new BasicHeader("Location", req.getRequestUri())); //$hasTaintFlow=y
}
}
void test2() {
ByteArrayBuffer bbuf = new ByteArrayBuffer(42);
bbuf.append((byte[]) taint(), 0, 3);
sink(bbuf.array()); //$hasTaintFlow=y
sink(bbuf.toByteArray()); //$hasTaintFlow=y
sink(bbuf.toString());
CharArrayBuffer cbuf = new CharArrayBuffer(42);
cbuf.append(bbuf.toByteArray(), 0, 3);
sink(cbuf.toCharArray()); //$hasTaintFlow=y
sink(cbuf.toString()); //$hasTaintFlow=y
sink(cbuf.subSequence(0, 3)); //$hasTaintFlow=y
sink(cbuf.substring(0, 3)); //$hasTaintFlow=y
sink(cbuf.substringTrimmed(0, 3)); //$hasTaintFlow=y
sink(Args.notNull(taint(), "x")); //$hasTaintFlow=y
sink(Args.notEmpty((String) taint(), "x")); //$hasTaintFlow=y
sink(Args.notBlank((String) taint(), "x")); //$hasTaintFlow=y
sink(Args.notNull("x", (String) taint()));
}
class Test3 implements HttpServerRequestHandler {
public void handle(ClassicHttpRequest req, HttpServerRequestHandler.ResponseTrigger restr, HttpContext ctx) throws HttpException, IOException {
B.sink(req.getEntity()); //$hasTaintFlow=y
}
}
}

View File

@@ -0,0 +1,39 @@
import java
import semmle.code.java.dataflow.TaintTracking
import semmle.code.java.dataflow.FlowSources
import semmle.code.java.security.XSS
import semmle.code.java.security.UrlRedirect
import TestUtilities.InlineExpectationsTest
class Conf extends TaintTracking::Configuration {
Conf() { this = "qltest:frameworks:apache-http" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getMethod().hasName("taint")
or
n instanceof RemoteFlowSource
}
override predicate isSink(DataFlow::Node n) {
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
or
n instanceof XssSink
or
n instanceof UrlRedirectSink
}
}
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
override string getARelevantTag() { result = "hasTaintFlow" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasTaintFlow" and
exists(DataFlow::Node src, DataFlow::Node sink, Conf conf | conf.hasFlow(src, sink) |
sink.getLocation() = location and
element = sink.toString() and
value = "y"
)
}
}

View File

@@ -0,0 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../stubs/apache-http-4.4.13:${testdir}/../../../stubs/apache-http-5

View File

@@ -1,8 +1,4 @@
/*
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/Header.java $
* $Revision: 569636 $
* $Date: 2007-08-25 00:34:47 -0700 (Sat, 25 Aug 2007) $
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -33,38 +29,25 @@ package org.apache.http;
/**
* Represents an HTTP header field.
*
* <p>
* The HTTP header fields follow the same generic format as that given in
* Section 3.1 of RFC 822. Each header field consists of a name followed by a
* colon (":") and the field value. Field names are case-insensitive. The field
* value MAY be preceded by any amount of LWS, though a single SP is preferred.
*
* <pre>
* <p>The HTTP header fields follow the same generic format as
* that given in Section 3.1 of RFC 822. Each header field consists
* of a name followed by a colon (":") and the field value. Field names
* are case-insensitive. The field value MAY be preceded by any amount
* of LWS, though a single SP is preferred.
*
*<pre>
* message-header = field-name ":" [ field-value ]
* field-name = token
* field-value = *( field-content | LWS )
* field-content = &lt;the OCTETs making up the field-value
* and consisting of either *TEXT or combinations
* of token, separators, and quoted-string&gt;
* </pre>
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
* @version $Revision: 569636 $
*</pre>
*
* @deprecated Please use {@link java.net.URL#openConnection} instead. Please
* visit <a href=
* "http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this
* webpage</a> for further details.
* @since 4.0
*/
@Deprecated
public interface Header {
String getName();
String getValue();
public interface Header extends NameValuePair {
HeaderElement[] getElements() throws ParseException;
}

View File

@@ -0,0 +1,55 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http;
import java.util.Locale;
public interface HttpResponse extends HttpMessage {
// StatusLine getStatusLine();
// void setStatusLine(StatusLine statusline);
// void setStatusLine(ProtocolVersion ver, int code);
// void setStatusLine(ProtocolVersion ver, int code, String reason);
void setStatusCode(int code)
throws IllegalStateException;
void setReasonPhrase(String reason)
throws IllegalStateException;
HttpEntity getEntity();
void setEntity(HttpEntity entity);
Locale getLocale();
void setLocale(Locale loc);
}

View File

@@ -0,0 +1,74 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.entity;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.Header;
public abstract class AbstractHttpEntity implements HttpEntity {
@Override
public Header getContentType() {
return null;
}
@Override
public Header getContentEncoding() {
return null;
}
@Override
public boolean isChunked() {
return false;
}
public void setContentType(final Header contentType) {
}
public void setContentType(final String ctString) {
}
public void setContentEncoding(final Header contentEncoding) {
}
public void setContentEncoding(final String ceString) {
}
public void setChunked(final boolean b) {
}
@Override
public void consumeContent() throws IOException {
}
@Override
public String toString() {
return null;
}
}

View File

@@ -0,0 +1,78 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.entity;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
public ByteArrayEntity(final byte[] b, final ContentType contentType) {
}
public ByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) {
}
public ByteArrayEntity(final byte[] b) {
}
public ByteArrayEntity(final byte[] b, final int off, final int len) {
}
@Override
public boolean isRepeatable() {
return false;
}
@Override
public long getContentLength() {
return 0;
}
@Override
public InputStream getContent() {
return null;
}
@Override
public void writeTo(final OutputStream outStream) throws IOException {
}
@Override
public boolean isStreaming() {
return false;
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
}

View File

@@ -0,0 +1,35 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.entity;
import java.io.Serializable;
public final class ContentType implements Serializable {
}

View File

@@ -0,0 +1,87 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.entity;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
public class StringEntity extends AbstractHttpEntity implements Cloneable {
public StringEntity(final String string, final ContentType contentType) throws UnsupportedCharsetException {
}
public StringEntity(
final String string, final String mimeType, final String charset) throws UnsupportedEncodingException {
}
public StringEntity(final String string, final String charset)
throws UnsupportedCharsetException {
}
public StringEntity(final String string, final Charset charset) {
}
public StringEntity(final String string)
throws UnsupportedEncodingException {
}
@Override
public boolean isRepeatable() {
return false;
}
@Override
public long getContentLength() {
return 0;
}
@Override
public InputStream getContent() throws IOException {
return null;
}
@Override
public void writeTo(final OutputStream outStream) throws IOException {
}
@Override
public boolean isStreaming() {
return false;
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
}

View File

@@ -0,0 +1,65 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.message;
import java.io.Serializable;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.ParseException;
public class BasicHeader implements Header, Cloneable, Serializable {
public BasicHeader(final String name, final String value) {
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
@Override
public HeaderElement[] getElements() throws ParseException {
return null;
}
@Override
public String getName() {
return null;
}
@Override
public String getValue() {
return null;
}
@Override
public String toString() {
return null;
}
}

View File

@@ -0,0 +1,37 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.protocol;
public interface HttpContext {
Object getAttribute(String id);
void setAttribute(String id, Object obj);
Object removeAttribute(String id);
}

View File

@@ -0,0 +1,38 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.protocol;
import java.io.IOException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
public interface HttpRequestHandler {
void handle(HttpRequest request, HttpResponse response, HttpContext context)
throws IOException;
}

View File

@@ -0,0 +1,78 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.util;
import java.util.Collection;
public class Args {
public static void check(final boolean expression, final String message) {
}
public static void check(final boolean expression, final String message, final Object... args) {
}
public static void check(final boolean expression, final String message, final Object arg) {
}
public static <T> T notNull(final T argument, final String name) {
return null;
}
public static <T extends CharSequence> T notEmpty(final T argument, final String name) {
return null;
}
public static <T extends CharSequence> T notBlank(final T argument, final String name) {
return null;
}
public static <T extends CharSequence> T containsNoBlanks(final T argument, final String name) {
return null;
}
public static <E, T extends Collection<E>> T notEmpty(final T argument, final String name) {
return null;
}
public static int positive(final int n, final String name) {
return 0;
}
public static long positive(final long n, final String name) {
return 0;
}
public static int notNegative(final int n, final String name) {
return 0;
}
public static long notNegative(final long n, final String name) {
return 0;
}
}

View File

@@ -0,0 +1,93 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.util;
import java.io.Serializable;
public final class ByteArrayBuffer implements Serializable {
public ByteArrayBuffer(final int capacity) {
}
public void append(final byte[] b, final int off, final int len) {
}
public void append(final int b) {
}
public void append(final char[] b, final int off, final int len) {
}
public void append(final CharArrayBuffer b, final int off, final int len) {
}
public void clear() {
}
public byte[] toByteArray() {
return null;
}
public int byteAt(final int i) {
return 0;
}
public int capacity() {
return 0;
}
public int length() {
return 0;
}
public void ensureCapacity(final int required) {
}
public byte[] buffer() {
return null;
}
public void setLength(final int len) {
}
public boolean isEmpty() {
return false;
}
public boolean isFull() {
return false;
}
public int indexOf(final byte b, final int from, final int to) {
return 0;
}
public int indexOf(final byte b) {
return 0;
}
}

View File

@@ -0,0 +1,127 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.util;
import java.io.Serializable;
import java.nio.CharBuffer;
public final class CharArrayBuffer implements CharSequence, Serializable {
public CharArrayBuffer(final int capacity) {
}
public void append(final char[] b, final int off, final int len) {
}
public void append(final String str) {
}
public void append(final CharArrayBuffer b, final int off, final int len) {
}
public void append(final CharArrayBuffer b) {
}
public void append(final char ch) {
}
public void append(final byte[] b, final int off, final int len) {
}
public void append(final ByteArrayBuffer b, final int off, final int len) {
}
public void append(final Object obj) {
}
public void clear() {
}
public char[] toCharArray() {
return null;
}
@Override
public char charAt(final int i) {
return 0;
}
public char[] buffer() {
return null;
}
public int capacity() {
return 0;
}
@Override
public int length() {
return 0;
}
public void ensureCapacity(final int required) {
}
public void setLength(final int len) {
}
public boolean isEmpty() {
return false;
}
public boolean isFull() {
return false;
}
public int indexOf(final int ch, final int from, final int to) {
return 0;
}
public int indexOf(final int ch) {
return 0;
}
public String substring(final int beginIndex, final int endIndex) {
return null;
}
public String substringTrimmed(final int beginIndex, final int endIndex) {
return null;
}
@Override
public CharSequence subSequence(final int beginIndex, final int endIndex) {
return null;
}
@Override
public String toString() {
return null;
}
}

View File

@@ -0,0 +1,72 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.util;
import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.http.*;
public final class EntityUtils {
public static void consumeQuietly(final HttpEntity entity) {
}
public static void consume(final HttpEntity entity) throws IOException {
}
public static void updateEntity(
final HttpResponse response, final HttpEntity entity) throws IOException {
}
public static byte[] toByteArray(final HttpEntity entity) throws IOException {
return null;
}
public static String getContentCharSet(final HttpEntity entity) {
return null;
}
public static String getContentMimeType(final HttpEntity entity) {
return null;
}
public static String toString(
final HttpEntity entity, final Charset defaultCharset) throws IOException {
return null;
}
public static String toString(
final HttpEntity entity, final String defaultCharset) throws IOException {
return null;
}
public static String toString(final HttpEntity entity) throws IOException, ParseException {
return null;
}
}

View File

@@ -0,0 +1,33 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.function;
public interface Supplier<T> {
T get();
}

View File

@@ -0,0 +1,36 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* 'Classic' {@link HttpRequest} message that can enclose {@link HttpEntity}.
*
* @since 5.0
*/
public interface ClassicHttpRequest extends HttpRequest, HttpEntityContainer {
}

View File

@@ -0,0 +1,33 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.io.Closeable;
public interface ClassicHttpResponse extends HttpResponse, HttpEntityContainer, Closeable {
}

View File

@@ -0,0 +1,159 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
public final class ContentType implements Serializable {
public static final ContentType APPLICATION_ATOM_XML = null;
public static final ContentType APPLICATION_FORM_URLENCODED = null;
public static final ContentType APPLICATION_JSON = null;
public static final ContentType APPLICATION_NDJSON = null;
public static final ContentType APPLICATION_OCTET_STREAM = null;
public static final ContentType APPLICATION_PDF = null;
public static final ContentType APPLICATION_SOAP_XML = null;
public static final ContentType APPLICATION_SVG_XML = null;
public static final ContentType APPLICATION_XHTML_XML = null;
public static final ContentType APPLICATION_XML = null;
public static final ContentType APPLICATION_PROBLEM_JSON = null;
public static final ContentType APPLICATION_PROBLEM_XML = null;
public static final ContentType APPLICATION_RSS_XML = null;
public static final ContentType IMAGE_BMP = null;
public static final ContentType IMAGE_GIF = null;
public static final ContentType IMAGE_JPEG = null;
public static final ContentType IMAGE_PNG = null;
public static final ContentType IMAGE_SVG = null;
public static final ContentType IMAGE_TIFF = null;
public static final ContentType IMAGE_WEBP = null;
public static final ContentType MULTIPART_FORM_DATA = null;
public static final ContentType MULTIPART_MIXED = null;
public static final ContentType MULTIPART_RELATED = null;
public static final ContentType TEXT_HTML = null;
public static final ContentType TEXT_MARKDOWN = null;
public static final ContentType TEXT_PLAIN = null;
public static final ContentType TEXT_XML = null;
public static final ContentType TEXT_EVENT_STREAM = null;
public static final ContentType WILDCARD = null;
private static final NameValuePair[] EMPTY_NAME_VALUE_PAIR_ARRAY = new NameValuePair[0];
public String getMimeType() {
return null;
}
public Charset getCharset() {
return null;
}
public String getParameter(final String name) {
return null;
}
@Override
public String toString() {
return null;
}
public static ContentType create(final String mimeType, final Charset charset) {
return null;
}
public static ContentType create(final String mimeType) {
return null;
}
public static ContentType create(
final String mimeType, final String charset) throws UnsupportedCharsetException {
return null;
}
public static ContentType create(
final String mimeType, final NameValuePair... params) throws UnsupportedCharsetException {
return null;
}
public static ContentType parse(final CharSequence s) throws UnsupportedCharsetException {
return null;
}
public static ContentType parseLenient(final CharSequence s) throws UnsupportedCharsetException {
return null;
}
public static ContentType getByMimeType(final String mimeType) {
return null;
}
public ContentType withCharset(final Charset charset) {
return null;
}
public ContentType withCharset(final String charset) {
return null;
}
public ContentType withParameters(
final NameValuePair... params) throws UnsupportedCharsetException {
return null;
}
public boolean isSameMimeType(final ContentType contentType) {
return false;
}
}

View File

@@ -0,0 +1,43 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.util.Set;
public interface EntityDetails {
long getContentLength();
String getContentType();
String getContentEncoding();
boolean isChunked();
Set<String> getTrailerNames();
}

View File

@@ -0,0 +1,39 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* Represents an HTTP header field consisting of a field name and a field
* value.
*
* @since 4.0
*/
public interface Header extends NameValuePair {
boolean isSensitive();
}

View File

@@ -0,0 +1,48 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.apache.hc.core5.function.Supplier;
public interface HttpEntity extends EntityDetails, Closeable {
boolean isRepeatable();
InputStream getContent() throws IOException, UnsupportedOperationException;
void writeTo(OutputStream outStream) throws IOException;
boolean isStreaming();
Supplier<List<? extends Header>> getTrailers();
}

View File

@@ -0,0 +1,40 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* Contains an {@link HttpEntity}.
*
* @since 5.0
*/
public interface HttpEntityContainer {
HttpEntity getEntity();
void setEntity(HttpEntity entity);
}

View File

@@ -0,0 +1,48 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* Signals that an HTTP exception has occurred.
*
* @since 4.0
*/
public class HttpException extends Exception {
public HttpException() {
}
public HttpException(final String message) {
}
public HttpException(final String format, final Object... args) {
}
public HttpException(final String message, final Throwable cause) {
}
}

View File

@@ -0,0 +1,55 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* HTTP messages consist of requests from client to server and responses
* from server to client.
*
* @since 4.0
*/
public interface HttpMessage extends MessageHeaders {
void setVersion(ProtocolVersion version);
ProtocolVersion getVersion();
void addHeader(Header header);
void addHeader(String name, Object value);
void setHeader(Header header);
void setHeader(String name, Object value);
void setHeaders(Header... headers);
boolean removeHeader(Header header);
boolean removeHeaders(String name);
}

View File

@@ -0,0 +1,56 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.hc.core5.net.URIAuthority;
public interface HttpRequest extends HttpMessage {
String getMethod();
String getPath();
void setPath(String path);
String getScheme();
void setScheme(String scheme);
URIAuthority getAuthority();
void setAuthority(URIAuthority authority);
String getRequestUri();
URI getUri() throws URISyntaxException;
void setUri(final URI requestUri);
}

View File

@@ -0,0 +1,45 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.util.Locale;
public interface HttpResponse extends HttpMessage {
int getCode();
void setCode(int code);
String getReasonPhrase();
void setReasonPhrase(String reason);
Locale getLocale();
void setLocale(Locale loc);
}

View File

@@ -0,0 +1,51 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.util.Iterator;
public interface MessageHeaders {
boolean containsHeader(String name);
int countHeaders(String name);
Header getFirstHeader(String name);
Header getHeader(String name) throws ProtocolException;
Header[] getHeaders();
Header[] getHeaders(String name);
Header getLastHeader(String name);
Iterator<Header> headerIterator();
Iterator<Header> headerIterator(String name);
}

View File

@@ -0,0 +1,40 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* A name-value pair parameter used as an element of HTTP messages.
*
* @since 4.0
*/
public interface NameValuePair {
String getName();
String getValue();
}

View File

@@ -0,0 +1,52 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* Signals a protocol exception due to failure to parse a message element.
*
* @since 4.0
*/
public class ParseException extends ProtocolException {
public ParseException() {
}
public ParseException(final String message) {
}
public ParseException(final String description, final CharSequence text, final int off, final int len, final int errorOffset) {
}
public ParseException(final String description, final CharSequence text, final int off, final int len) {
}
public int getErrorOffset() {
return 0;
}
}

View File

@@ -0,0 +1,49 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
/**
* Signals that an HTTP protocol violation has occurred.
* For example a malformed status line or headers, a missing message body, etc.
*
* @since 4.0
*/
public class ProtocolException extends HttpException {
public ProtocolException() {
}
public ProtocolException(final String message) {
}
public ProtocolException(final String format, final Object... args) {
}
public ProtocolException(final String message, final Throwable cause) {
}
}

View File

@@ -0,0 +1,87 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http;
import java.io.Serializable;
public class ProtocolVersion implements Serializable {
public ProtocolVersion(final String protocol, final int major, final int minor) {
}
public final String getProtocol() {
return null;
}
public final int getMajor() {
return 0;
}
public final int getMinor() {
return 0;
}
@Override
public final int hashCode() {
return 0;
}
public final boolean equals(final int major, final int minor) {
return false;
}
@Override
public final boolean equals(final Object obj) {
return false;
}
public String format() {
return null;
}
public boolean isComparable(final ProtocolVersion that) {
return false;
}
public int compareToVersion(final ProtocolVersion that) {
return 0;
}
public final boolean greaterEquals(final ProtocolVersion version) {
return false;
}
public final boolean lessEquals(final ProtocolVersion version) {
return false;
}
@Override
public String toString() {
return null;
}
}

View File

@@ -0,0 +1,41 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io;
import java.io.IOException;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.protocol.HttpContext;
public interface HttpRequestHandler {
void handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)
throws HttpException, IOException;
}

View File

@@ -0,0 +1,46 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io;
import java.io.IOException;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.protocol.HttpContext;
public interface HttpServerRequestHandler {
interface ResponseTrigger {
void sendInformation(ClassicHttpResponse response) throws HttpException, IOException;
void submitResponse(ClassicHttpResponse response) throws HttpException, IOException;
}
void handle(
ClassicHttpRequest request,
ResponseTrigger responseTrigger,
HttpContext context) throws HttpException, IOException;
}

View File

@@ -0,0 +1,86 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io.entity;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.util.Args;
public abstract class AbstractHttpEntity implements HttpEntity {
public static void writeTo(final HttpEntity entity, final OutputStream outStream) throws IOException {
}
@Override
public void writeTo(final OutputStream outStream) throws IOException {
}
@Override
public final String getContentType() {
return null;
}
@Override
public final String getContentEncoding() {
return null;
}
@Override
public final boolean isChunked() {
return false;
}
@Override
public boolean isRepeatable() {
return false;
}
@Override
public Supplier<List<? extends Header>> getTrailers() {
return null;
}
@Override
public Set<String> getTrailerNames() {
return null;
}
@Override
public String toString() {
return null;
}
}

View File

@@ -0,0 +1,92 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io.entity;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.hc.core5.http.ContentType;
public class ByteArrayEntity extends AbstractHttpEntity {
public ByteArrayEntity(
final byte[] b, final int off, final int len, final ContentType contentType, final String contentEncoding,
final boolean chunked) {
}
public ByteArrayEntity(
final byte[] b, final int off, final int len, final ContentType contentType, final String contentEncoding) {
}
public ByteArrayEntity(
final byte[] b, final ContentType contentType, final String contentEncoding, final boolean chunked) {
}
public ByteArrayEntity(final byte[] b, final ContentType contentType, final String contentEncoding) {
}
public ByteArrayEntity(final byte[] b, final ContentType contentType, final boolean chunked) {
}
public ByteArrayEntity(final byte[] b, final ContentType contentType) {
}
public ByteArrayEntity(
final byte[] b, final int off, final int len, final ContentType contentType, final boolean chunked) {
}
public ByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) {
}
@Override
public final boolean isRepeatable() {
return false;
}
@Override
public final long getContentLength() {
return 0;
}
@Override
public final InputStream getContent() {
return null;
}
@Override
public final void writeTo(final OutputStream outStream) throws IOException {
}
@Override
public final boolean isStreaming() {
return false;
}
@Override
public final void close() throws IOException {
}
}

View File

@@ -0,0 +1,65 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io.entity;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import org.apache.hc.core5.http.ContentType;
public class ByteBufferEntity extends AbstractHttpEntity {
public ByteBufferEntity(final ByteBuffer buffer, final ContentType contentType, final String contentEncoding) {
}
public ByteBufferEntity(final ByteBuffer buffer, final ContentType contentType) {
}
@Override
public final boolean isRepeatable() {
return false;
}
@Override
public final long getContentLength() {
return 0;
}
@Override
public final InputStream getContent() throws IOException, UnsupportedOperationException {
return null;
}
@Override
public final boolean isStreaming() {
return false;
}
@Override
public final void close() throws IOException {
}
}

View File

@@ -0,0 +1,89 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io.entity;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.ParseException;
public final class EntityUtils {
public static void consumeQuietly(final HttpEntity entity) {
}
public static void consume(final HttpEntity entity) throws IOException {
}
public static byte[] toByteArray(final HttpEntity entity) throws IOException {
return null;
}
public static byte[] toByteArray(final HttpEntity entity, final int maxResultLength) throws IOException {
return null;
}
public static String toString(
final HttpEntity entity, final Charset defaultCharset) throws IOException, ParseException {
return null;
}
public static String toString(
final HttpEntity entity, final Charset defaultCharset, final int maxResultLength) throws IOException, ParseException {
return null;
}
public static String toString(
final HttpEntity entity, final String defaultCharset) throws IOException, ParseException {
return null;
}
public static String toString(
final HttpEntity entity, final String defaultCharset, final int maxResultLength) throws IOException, ParseException {
return null;
}
public static String toString(final HttpEntity entity) throws IOException, ParseException {
return null;
}
public static String toString(final HttpEntity entity, final int maxResultLength) throws IOException, ParseException {
return null;
}
public static List<NameValuePair> parse(final HttpEntity entity) throws IOException {
return null;
}
public static List<NameValuePair> parse(final HttpEntity entity, final int maxStreamLength) throws IOException {
return null;
}
}

View File

@@ -0,0 +1,152 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io.entity;
import java.io.File;
import java.io.OutputStream;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.file.Path;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.io.IOCallback;
public final class HttpEntities {
public static HttpEntity create(final String content, final ContentType contentType) {
return null;
}
public static HttpEntity create(final String content, final Charset charset) {
return null;
}
public static HttpEntity create(final String content) {
return null;
}
public static HttpEntity create(final byte[] content, final ContentType contentType) {
return null;
}
public static HttpEntity create(final File content, final ContentType contentType) {
return null;
}
public static HttpEntity create(final Serializable serializable, final ContentType contentType) {
return null;
}
public static HttpEntity createUrlEncoded(
final Iterable <? extends NameValuePair> parameters, final Charset charset) {
return null;
}
public static HttpEntity create(final IOCallback<OutputStream> callback, final ContentType contentType) {
return null;
}
public static HttpEntity gzip(final HttpEntity entity) {
return null;
}
public static HttpEntity createGzipped(final String content, final ContentType contentType) {
return null;
}
public static HttpEntity createGzipped(final String content, final Charset charset) {
return null;
}
public static HttpEntity createGzipped(final String content) {
return null;
}
public static HttpEntity createGzipped(final byte[] content, final ContentType contentType) {
return null;
}
public static HttpEntity createGzipped(final File content, final ContentType contentType) {
return null;
}
public static HttpEntity createGzipped(final Serializable serializable, final ContentType contentType) {
return null;
}
public static HttpEntity createGzipped(final IOCallback<OutputStream> callback, final ContentType contentType) {
return null;
}
public static HttpEntity createGzipped(final Path content, final ContentType contentType) {
return null;
}
public static HttpEntity withTrailers(final HttpEntity entity, final Header... trailers) {
return null;
}
public static HttpEntity create(final String content, final ContentType contentType, final Header... trailers) {
return null;
}
public static HttpEntity create(final String content, final Charset charset, final Header... trailers) {
return null;
}
public static HttpEntity create(final String content, final Header... trailers) {
return null;
}
public static HttpEntity create(final byte[] content, final ContentType contentType, final Header... trailers) {
return null;
}
public static HttpEntity create(final File content, final ContentType contentType, final Header... trailers) {
return null;
}
public static HttpEntity create(
final Serializable serializable, final ContentType contentType, final Header... trailers) {
return null;
}
public static HttpEntity create(
final IOCallback<OutputStream> callback, final ContentType contentType, final Header... trailers) {
return null;
}
public static HttpEntity create(final Path content, final ContentType contentType) {
return null;
}
public static HttpEntity create(final Path content, final ContentType contentType, final Header... trailers) {
return null;
}
}

View File

@@ -0,0 +1,83 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.io.entity;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import org.apache.hc.core5.http.ContentType;
public class StringEntity extends AbstractHttpEntity {
public StringEntity(
final String string, final ContentType contentType, final String contentEncoding, final boolean chunked) {
}
public StringEntity(final String string, final ContentType contentType, final boolean chunked) {
}
public StringEntity(final String string, final ContentType contentType) {
}
public StringEntity(final String string, final Charset charset) {
}
public StringEntity(final String string, final Charset charset, final boolean chunked) {
}
public StringEntity(final String string) {
}
@Override
public final boolean isRepeatable() {
return false;
}
@Override
public final long getContentLength() {
return 0;
}
@Override
public final InputStream getContent() throws IOException {
return null;
}
@Override
public final void writeTo(final OutputStream outStream) throws IOException {
}
@Override
public final boolean isStreaming() {
return false;
}
@Override
public final void close() throws IOException {
}
}

View File

@@ -0,0 +1,59 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.message;
import java.io.Serializable;
import org.apache.hc.core5.http.Header;
public class BasicHeader implements Header, Cloneable, Serializable {
public BasicHeader(final String name, final Object value) {
}
public BasicHeader(final String name, final Object value, final boolean sensitive) {
}
@Override
public String getName() {
return null;
}
@Override
public String getValue() {
return null;
}
@Override
public boolean isSensitive() {
return false;
}
@Override
public String toString() {
return null;
}
}

View File

@@ -0,0 +1,61 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.message;
import java.io.Serializable;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.ProtocolVersion;
public final class RequestLine implements Serializable {
public RequestLine(final HttpRequest request) {
}
public RequestLine(final String method,
final String uri,
final ProtocolVersion version) {
}
public String getMethod() {
return null;
}
public ProtocolVersion getProtocolVersion() {
return null;
}
public String getUri() {
return null;
}
@Override
public String toString() {
return null;
}
}

View File

@@ -0,0 +1,42 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.http.protocol;
import org.apache.hc.core5.http.ProtocolVersion;
public interface HttpContext {
ProtocolVersion getProtocolVersion();
void setProtocolVersion(ProtocolVersion version);
Object getAttribute(String id);
Object setAttribute(String id, Object obj);
Object removeAttribute(String id);
}

View File

@@ -0,0 +1,34 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.io;
import java.io.IOException;
public interface IOCallback<T> {
void execute(T object) throws IOException;
}

View File

@@ -0,0 +1,55 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.net;
public final class URIAuthority {
public String getUserInfo() {
return null;
}
public String getHostName() {
return null;
}
public int getPort() {
return 0;
}
public String toString() {
return null;
}
public boolean equals(final Object obj) {
return false;
}
public int hashCode() {
return 0;
}
}

View File

@@ -0,0 +1,93 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.util;
import org.apache.hc.core5.http.EntityDetails;
import java.util.Collection;
public class Args {
public static void check(final boolean expression, final String message) {
}
public static void check(final boolean expression, final String message, final Object... args) {
}
public static void check(final boolean expression, final String message, final Object arg) {
}
public static long checkContentLength(final EntityDetails entityDetails) {
return 0;
}
public static int checkRange(final int value, final int lowInclusive, final int highInclusive,
final String message) {
return 0;
}
public static long checkRange(final long value, final long lowInclusive, final long highInclusive,
final String message) {
return 0;
}
public static <T extends CharSequence> T containsNoBlanks(final T argument, final String name) {
return null;
}
public static <T extends CharSequence> T notBlank(final T argument, final String name) {
return null;
}
public static <T extends CharSequence> T notEmpty(final T argument, final String name) {
return null;
}
public static <E, T extends Collection<E>> T notEmpty(final T argument, final String name) {
return null;
}
public static int notNegative(final int n, final String name) {
return 0;
}
public static long notNegative(final long n, final String name) {
return 0;
}
public static <T> T notNull(final T argument, final String name) {
return null;
}
public static int positive(final int n, final String name) {
return 0;
}
public static long positive(final long n, final String name) {
return 0;
}
}

View File

@@ -0,0 +1,97 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.util;
import java.io.Serializable;
import java.nio.ByteBuffer;
public final class ByteArrayBuffer implements Serializable {
public ByteArrayBuffer(final int capacity) {
}
public void append(final byte[] b, final int off, final int len) {
}
public void append(final int b) {
}
public void append(final char[] b, final int off, final int len) {
}
public void append(final CharArrayBuffer b, final int off, final int len) {
}
public void append(final ByteBuffer buffer) {
}
public void clear() {
}
public byte[] toByteArray() {
return null;
}
public int byteAt(final int i) {
return 0;
}
public int capacity() {
return 0;
}
public int length() {
return 0;
}
public void ensureCapacity(final int required) {
}
public byte[] array() {
return null;
}
public void setLength(final int len) {
}
public boolean isEmpty() {
return false;
}
public boolean isFull() {
return false;
}
public int indexOf(final byte b, final int from, final int to) {
return 0;
}
public int indexOf(final byte b) {
return 0;
}
}

View File

@@ -0,0 +1,125 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.core5.util;
import java.io.Serializable;
public final class CharArrayBuffer implements CharSequence, Serializable {
public CharArrayBuffer(final int capacity) {
}
public void append(final char[] b, final int off, final int len) {
}
public void append(final String str) {
}
public void append(final CharArrayBuffer b, final int off, final int len) {
}
public void append(final CharArrayBuffer b) {
}
public void append(final char ch) {
}
public void append(final byte[] b, final int off, final int len) {
}
public void append(final ByteArrayBuffer b, final int off, final int len) {
}
public void append(final Object obj) {
}
public void clear() {
}
public char[] toCharArray() {
return null;
}
@Override
public char charAt(final int i) {
return 0;
}
public char[] array() {
return null;
}
public int capacity() {
return 0;
}
@Override
public int length() {
return 0;
}
public void ensureCapacity(final int required) {
}
public void setLength(final int len) {
}
public boolean isEmpty() {
return false;
}
public boolean isFull() {
return false;
}
public int indexOf(final int ch, final int from, final int to) {
return 0;
}
public int indexOf(final int ch) {
return 0;
}
public String substring(final int beginIndex, final int endIndex) {
return null;
}
public String substringTrimmed(final int beginIndex, final int endIndex) {
return null;
}
@Override
public CharSequence subSequence(final int beginIndex, final int endIndex) {
return null;
}
@Override
public String toString() {
return null;
}
}