mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge pull request #3976 from luchua-bc/java-unsecure-basic-auth
Java: Insecure basic authentication
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
public class InsecureBasicAuth {
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP request.
|
||||
*/
|
||||
public void testApacheHttpRequest(String username, String password) {
|
||||
{
|
||||
// BAD: basic authentication over HTTP
|
||||
String url = "http://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
}
|
||||
|
||||
{
|
||||
// GOOD: basic authentication over HTTPS
|
||||
String url = "https://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
}
|
||||
|
||||
HttpPost post = new HttpPost(url);
|
||||
post.setHeader("Accept", "application/json");
|
||||
post.setHeader("Content-type", "application/json");
|
||||
|
||||
String authString = username + ":" + password;
|
||||
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
|
||||
post.addHeader("Authorization", "Basic " + authStringEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Java HTTP URL connection.
|
||||
*/
|
||||
public void testHttpUrlConnection(String username, String password) {
|
||||
{
|
||||
// BAD: basic authentication over HTTP
|
||||
String urlStr = "http://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
}
|
||||
|
||||
{
|
||||
// GOOD: basic authentication over HTTPS
|
||||
String urlStr = "https://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
}
|
||||
|
||||
String authString = username + ":" + password;
|
||||
String encoding = Base64.getEncoder().encodeToString(authString.getBytes("UTF-8"));
|
||||
URL url = new URL(urlStr);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestProperty("Authorization", "Basic " + encoding);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
|
||||
<qhelp>
|
||||
|
||||
<overview>
|
||||
<p>Basic authentication only obfuscates username/password in Base64 encoding, which can be easily recognized and reversed, thus it must not be transmitted over the cleartext HTTP channel. Transmission of sensitive information not in HTTPS is vulnerable to packet sniffing.</p>
|
||||
</overview>
|
||||
|
||||
<recommendation>
|
||||
<p>Either use a more secure authentication mechanism like digest authentication or federated authentication, or use the HTTPS communication protocol.</p>
|
||||
</recommendation>
|
||||
|
||||
<example>
|
||||
<p>The following example shows two ways of using basic authentication. In the 'BAD' case, the credentials are transmitted over HTTP. In the 'GOOD' case, the credentials are transmitted over HTTPS.</p>
|
||||
<sample src="InsecureBasicAuth.java" />
|
||||
</example>
|
||||
|
||||
<references>
|
||||
<li>
|
||||
<a href="https://cwe.mitre.org/data/definitions/522">CWE-522</a>
|
||||
</li>
|
||||
<li>
|
||||
SonarSource rule:
|
||||
<a href="https://rules.sonarsource.com/java/tag/owasp/RSPEC-2647">Basic authentication should not be used</a>
|
||||
</li>
|
||||
<li>
|
||||
Acunetix:
|
||||
<a href="https://www.acunetix.com/vulnerabilities/web/basic-authentication-over-http/">WEB VULNERABILITIES INDEX - Basic authentication over HTTP</a>
|
||||
</li>
|
||||
</references>
|
||||
</qhelp>
|
||||
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
* @name Insecure basic authentication
|
||||
* @description Basic authentication only obfuscates username/password in Base64 encoding, which can be easily recognized and reversed. Transmission of sensitive information not over HTTPS is vulnerable to packet sniffing.
|
||||
* @kind path-problem
|
||||
* @id java/insecure-basic-auth
|
||||
* @tags security
|
||||
* external/cwe-522
|
||||
* external/cwe-319
|
||||
*/
|
||||
|
||||
import java
|
||||
import semmle.code.java.frameworks.Networking
|
||||
import semmle.code.java.dataflow.TaintTracking
|
||||
import DataFlow::PathGraph
|
||||
|
||||
/**
|
||||
* Gets a regular expression for matching private hosts, which only matches the host portion therefore checking for port is not necessary.
|
||||
*/
|
||||
private string getPrivateHostRegex() {
|
||||
result =
|
||||
"(?i)localhost(?:[:/?#].*)?|127\\.0\\.0\\.1(?:[:/?#].*)?|10(?:\\.[0-9]+){3}(?:[:/?#].*)?|172\\.16(?:\\.[0-9]+){2}(?:[:/?#].*)?|192.168(?:\\.[0-9]+){2}(?:[:/?#].*)?|\\[?0:0:0:0:0:0:0:1\\]?(?:[:/?#].*)?|\\[?::1\\]?(?:[:/?#].*)?"
|
||||
}
|
||||
|
||||
/**
|
||||
* The Java class `org.apache.http.client.methods.HttpRequestBase`. Popular subclasses include `HttpGet`, `HttpPost`, and `HttpPut`.
|
||||
* And the Java class `org.apache.http.message.BasicHttpRequest`.
|
||||
*/
|
||||
class ApacheHttpRequest extends RefType {
|
||||
ApacheHttpRequest() {
|
||||
this
|
||||
.getASourceSupertype*()
|
||||
.hasQualifiedName("org.apache.http.client.methods", "HttpRequestBase") or
|
||||
this.getASourceSupertype*().hasQualifiedName("org.apache.http.message", "BasicHttpRequest")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class of Java URL constructor.
|
||||
*/
|
||||
class URLConstructor extends ClassInstanceExpr {
|
||||
URLConstructor() { this.getConstructor().getDeclaringType() instanceof TypeUrl }
|
||||
|
||||
predicate hasHttpStringArg() {
|
||||
this.getConstructor().getParameter(0).getType() instanceof TypeString and
|
||||
(
|
||||
// URLs constructed with any of the three string constructors below:
|
||||
// `URL(String protocol, String host, int port, String file)`,
|
||||
// `URL(String protocol, String host, int port, String file, URLStreamHandler handler)`,
|
||||
// `URL(String protocol, String host, String file)`
|
||||
this.getConstructor().getNumberOfParameters() > 1 and
|
||||
concatHttpString(getArgument(0), this.getArgument(1)) // First argument contains the protocol part and the second argument contains the host part.
|
||||
or
|
||||
// URLs constructed with the string constructor `URL(String spec)`
|
||||
this.getConstructor().getNumberOfParameters() = 1 and
|
||||
this.getArgument(0) instanceof HttpString // First argument contains the whole spec.
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class of Java URI constructor.
|
||||
*/
|
||||
class URIConstructor extends ClassInstanceExpr {
|
||||
URIConstructor() { this.getConstructor().getDeclaringType().hasQualifiedName("java.net", "URI") }
|
||||
|
||||
predicate hasHttpStringArg() {
|
||||
(
|
||||
this.getNumArgument() = 1 and
|
||||
this.getArgument(0) instanceof HttpString // `URI(String str)`
|
||||
or
|
||||
this.getNumArgument() = 4 and
|
||||
concatHttpString(this.getArgument(0), this.getArgument(1)) // `URI(String scheme, String host, String path, String fragment)`
|
||||
or
|
||||
this.getNumArgument() = 5 and
|
||||
concatHttpString(this.getArgument(0), this.getArgument(1)) // `URI(String scheme, String authority, String path, String query, String fragment)` without user-info in authority
|
||||
or
|
||||
this.getNumArgument() = 7 and
|
||||
concatHttpString(this.getArgument(0), this.getArgument(2)) // `URI(String scheme, String userInfo, String host, int port, String path, String query, String fragment)`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* String of HTTP URLs not in private domains.
|
||||
*/
|
||||
class HttpStringLiteral extends StringLiteral {
|
||||
HttpStringLiteral() {
|
||||
// Match URLs with the HTTP protocol and without private IP addresses to reduce false positives.
|
||||
exists(string s | this.getRepresentedString() = s |
|
||||
s.regexpMatch("(?i)http://[\\[a-zA-Z0-9].*") and
|
||||
not s.substring(7, s.length()).regexpMatch(getPrivateHostRegex())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks both parts of protocol and host.
|
||||
*/
|
||||
predicate concatHttpString(Expr protocol, Expr host) {
|
||||
(
|
||||
protocol.(CompileTimeConstantExpr).getStringValue().regexpMatch("(?i)http(://)?") or
|
||||
protocol
|
||||
.(VarAccess)
|
||||
.getVariable()
|
||||
.getAnAssignedValue()
|
||||
.(CompileTimeConstantExpr)
|
||||
.getStringValue()
|
||||
.regexpMatch("(?i)http(://)?")
|
||||
) and
|
||||
not exists(string hostString |
|
||||
hostString = host.(CompileTimeConstantExpr).getStringValue() or
|
||||
hostString =
|
||||
host.(VarAccess).getVariable().getAnAssignedValue().(CompileTimeConstantExpr).getStringValue()
|
||||
|
|
||||
hostString.length() = 0 or // Empty host is loopback address
|
||||
hostString.regexpMatch(getPrivateHostRegex())
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the leftmost operand in a concatenated string */
|
||||
Expr getLeftmostConcatOperand(Expr expr) {
|
||||
if expr instanceof AddExpr
|
||||
then result = getLeftmostConcatOperand(expr.(AddExpr).getLeftOperand())
|
||||
else result = expr
|
||||
}
|
||||
|
||||
/**
|
||||
* String concatenated with `HttpStringLiteral`.
|
||||
*/
|
||||
class HttpString extends Expr {
|
||||
HttpString() {
|
||||
this instanceof HttpStringLiteral
|
||||
or
|
||||
concatHttpString(this.(AddExpr).getLeftOperand(),
|
||||
getLeftmostConcatOperand(this.(AddExpr).getRightOperand()))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* String pattern of basic authentication.
|
||||
*/
|
||||
class BasicAuthString extends StringLiteral {
|
||||
BasicAuthString() { exists(string s | this.getRepresentedString() = s | s.matches("Basic %")) }
|
||||
}
|
||||
|
||||
/**
|
||||
* String concatenated with `BasicAuthString`.
|
||||
*/
|
||||
predicate builtFromBasicAuthStringConcat(Expr expr) {
|
||||
expr instanceof BasicAuthString
|
||||
or
|
||||
builtFromBasicAuthStringConcat(expr.(AddExpr).getLeftOperand())
|
||||
or
|
||||
exists(Expr other | builtFromBasicAuthStringConcat(other) |
|
||||
exists(Variable var | var.getAnAssignedValue() = other and var.getAnAccess() = expr)
|
||||
)
|
||||
}
|
||||
|
||||
/** The `openConnection` method of Java URL. Not to include `openStream` since it won't be used in this query. */
|
||||
class HttpURLOpenMethod extends Method {
|
||||
HttpURLOpenMethod() {
|
||||
this.getDeclaringType() instanceof TypeUrl and
|
||||
this.getName() = "openConnection"
|
||||
}
|
||||
}
|
||||
|
||||
/** Constructor of `ApacheHttpRequest` */
|
||||
predicate apacheHttpRequest(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(ConstructorCall cc |
|
||||
cc.getConstructedType() instanceof ApacheHttpRequest and
|
||||
node2.asExpr() = cc and
|
||||
cc.getAnArgument() = node1.asExpr()
|
||||
)
|
||||
}
|
||||
|
||||
/** `URI` methods */
|
||||
predicate createURI(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(
|
||||
URIConstructor cc // new URI
|
||||
|
|
||||
node2.asExpr() = cc and
|
||||
cc.getArgument(0) = node1.asExpr()
|
||||
)
|
||||
or
|
||||
exists(
|
||||
StaticMethodAccess ma // URI.create
|
||||
|
|
||||
ma.getMethod().getDeclaringType().hasQualifiedName("java.net", "URI") and
|
||||
ma.getMethod().hasName("create") and
|
||||
node1.asExpr() = ma.getArgument(0) and
|
||||
node2.asExpr() = ma
|
||||
)
|
||||
}
|
||||
|
||||
/** Constructors of `URL` */
|
||||
predicate createURL(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(URLConstructor cc |
|
||||
node2.asExpr() = cc and
|
||||
cc.getArgument(0) = node1.asExpr()
|
||||
)
|
||||
}
|
||||
|
||||
/** Method call of `HttpURLOpenMethod` */
|
||||
predicate urlOpen(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(MethodAccess ma |
|
||||
ma.getMethod() instanceof HttpURLOpenMethod and
|
||||
node1.asExpr() = ma.getQualifier() and
|
||||
ma = node2.asExpr()
|
||||
)
|
||||
}
|
||||
|
||||
/** Constructor of `BasicRequestLine` */
|
||||
predicate basicRequestLine(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(ConstructorCall mcc |
|
||||
mcc.getConstructedType().hasQualifiedName("org.apache.http.message", "BasicRequestLine") and
|
||||
mcc.getArgument(1) = node1.asExpr() and // `BasicRequestLine(String method, String uri, ProtocolVersion version)
|
||||
node2.asExpr() = mcc
|
||||
)
|
||||
}
|
||||
|
||||
class BasicAuthFlowConfig extends TaintTracking::Configuration {
|
||||
BasicAuthFlowConfig() { this = "InsecureBasicAuth::BasicAuthFlowConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node src) {
|
||||
src.asExpr() instanceof HttpString
|
||||
or
|
||||
exists(URLConstructor uc |
|
||||
uc.hasHttpStringArg() and
|
||||
src.asExpr() = uc.getArgument(0)
|
||||
)
|
||||
or
|
||||
exists(URIConstructor uc |
|
||||
uc.hasHttpStringArg() and
|
||||
src.asExpr() = uc.getArgument(0)
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(MethodAccess ma |
|
||||
sink.asExpr() = ma.getQualifier() and
|
||||
(
|
||||
ma.getMethod().hasName("addHeader") or
|
||||
ma.getMethod().hasName("setHeader") or
|
||||
ma.getMethod().hasName("setRequestProperty")
|
||||
) and
|
||||
ma.getArgument(0).(CompileTimeConstantExpr).getStringValue() = "Authorization" and
|
||||
builtFromBasicAuthStringConcat(ma.getArgument(1))
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
apacheHttpRequest(node1, node2) or
|
||||
createURI(node1, node2) or
|
||||
basicRequestLine(node1, node2) or
|
||||
createURL(node1, node2) or
|
||||
urlOpen(node1, node2)
|
||||
}
|
||||
}
|
||||
|
||||
from DataFlow::PathNode source, DataFlow::PathNode sink, BasicAuthFlowConfig config
|
||||
where config.hasFlowPath(source, sink)
|
||||
select sink.getNode(), source, sink, "Insecure basic authentication from $@.", source.getNode(),
|
||||
"HTTP url"
|
||||
@@ -0,0 +1,43 @@
|
||||
edges
|
||||
| InsecureBasicAuth.java:20:39:20:52 | ... + ... : String | InsecureBasicAuth.java:28:3:28:6 | post |
|
||||
| InsecureBasicAuth.java:35:19:35:64 | "http://www.example.com:8000/payment/retrieve" : String | InsecureBasicAuth.java:38:3:38:5 | get |
|
||||
| InsecureBasicAuth.java:45:19:45:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:54:3:54:6 | post |
|
||||
| InsecureBasicAuth.java:61:19:61:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:71:3:71:6 | post |
|
||||
| InsecureBasicAuth.java:78:47:78:52 | "http" : String | InsecureBasicAuth.java:86:3:86:6 | post |
|
||||
| InsecureBasicAuth.java:93:19:93:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:102:3:102:6 | post |
|
||||
| InsecureBasicAuth.java:109:19:109:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:119:3:119:6 | post |
|
||||
| InsecureBasicAuth.java:126:19:126:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:130:28:130:67 | (...)... : URLConnection |
|
||||
| InsecureBasicAuth.java:130:28:130:67 | (...)... : URLConnection | InsecureBasicAuth.java:133:3:133:6 | conn |
|
||||
| InsecureBasicAuth.java:145:21:145:28 | protocol : String | InsecureBasicAuth.java:146:28:146:67 | (...)... : URLConnection |
|
||||
| InsecureBasicAuth.java:146:28:146:67 | (...)... : URLConnection | InsecureBasicAuth.java:149:3:149:6 | conn |
|
||||
nodes
|
||||
| InsecureBasicAuth.java:20:39:20:52 | ... + ... : String | semmle.label | ... + ... : String |
|
||||
| InsecureBasicAuth.java:28:3:28:6 | post | semmle.label | post |
|
||||
| InsecureBasicAuth.java:35:19:35:64 | "http://www.example.com:8000/payment/retrieve" : String | semmle.label | "http://www.example.com:8000/payment/retrieve" : String |
|
||||
| InsecureBasicAuth.java:38:3:38:5 | get | semmle.label | get |
|
||||
| InsecureBasicAuth.java:45:19:45:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | semmle.label | "http://www.example.com/rest/getuser.do?uid=abcdx" : String |
|
||||
| InsecureBasicAuth.java:54:3:54:6 | post | semmle.label | post |
|
||||
| InsecureBasicAuth.java:61:19:61:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | semmle.label | "http://www.example.com/rest/getuser.do?uid=abcdx" : String |
|
||||
| InsecureBasicAuth.java:71:3:71:6 | post | semmle.label | post |
|
||||
| InsecureBasicAuth.java:78:47:78:52 | "http" : String | semmle.label | "http" : String |
|
||||
| InsecureBasicAuth.java:86:3:86:6 | post | semmle.label | post |
|
||||
| InsecureBasicAuth.java:93:19:93:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | semmle.label | "http://www.example.com/rest/getuser.do?uid=abcdx" : String |
|
||||
| InsecureBasicAuth.java:102:3:102:6 | post | semmle.label | post |
|
||||
| InsecureBasicAuth.java:109:19:109:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | semmle.label | "http://www.example.com/rest/getuser.do?uid=abcdx" : String |
|
||||
| InsecureBasicAuth.java:119:3:119:6 | post | semmle.label | post |
|
||||
| InsecureBasicAuth.java:126:19:126:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | semmle.label | "http://www.example.com/rest/getuser.do?uid=abcdx" : String |
|
||||
| InsecureBasicAuth.java:130:28:130:67 | (...)... : URLConnection | semmle.label | (...)... : URLConnection |
|
||||
| InsecureBasicAuth.java:133:3:133:6 | conn | semmle.label | conn |
|
||||
| InsecureBasicAuth.java:145:21:145:28 | protocol : String | semmle.label | protocol : String |
|
||||
| InsecureBasicAuth.java:146:28:146:67 | (...)... : URLConnection | semmle.label | (...)... : URLConnection |
|
||||
| InsecureBasicAuth.java:149:3:149:6 | conn | semmle.label | conn |
|
||||
#select
|
||||
| InsecureBasicAuth.java:28:3:28:6 | post | InsecureBasicAuth.java:20:39:20:52 | ... + ... : String | InsecureBasicAuth.java:28:3:28:6 | post | Insecure basic authentication from $@. | InsecureBasicAuth.java:20:39:20:52 | ... + ... | HTTP url |
|
||||
| InsecureBasicAuth.java:38:3:38:5 | get | InsecureBasicAuth.java:35:19:35:64 | "http://www.example.com:8000/payment/retrieve" : String | InsecureBasicAuth.java:38:3:38:5 | get | Insecure basic authentication from $@. | InsecureBasicAuth.java:35:19:35:64 | "http://www.example.com:8000/payment/retrieve" | HTTP url |
|
||||
| InsecureBasicAuth.java:54:3:54:6 | post | InsecureBasicAuth.java:45:19:45:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:54:3:54:6 | post | Insecure basic authentication from $@. | InsecureBasicAuth.java:45:19:45:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" | HTTP url |
|
||||
| InsecureBasicAuth.java:71:3:71:6 | post | InsecureBasicAuth.java:61:19:61:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:71:3:71:6 | post | Insecure basic authentication from $@. | InsecureBasicAuth.java:61:19:61:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" | HTTP url |
|
||||
| InsecureBasicAuth.java:86:3:86:6 | post | InsecureBasicAuth.java:78:47:78:52 | "http" : String | InsecureBasicAuth.java:86:3:86:6 | post | Insecure basic authentication from $@. | InsecureBasicAuth.java:78:47:78:52 | "http" | HTTP url |
|
||||
| InsecureBasicAuth.java:102:3:102:6 | post | InsecureBasicAuth.java:93:19:93:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:102:3:102:6 | post | Insecure basic authentication from $@. | InsecureBasicAuth.java:93:19:93:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" | HTTP url |
|
||||
| InsecureBasicAuth.java:119:3:119:6 | post | InsecureBasicAuth.java:109:19:109:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:119:3:119:6 | post | Insecure basic authentication from $@. | InsecureBasicAuth.java:109:19:109:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" | HTTP url |
|
||||
| InsecureBasicAuth.java:133:3:133:6 | conn | InsecureBasicAuth.java:126:19:126:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" : String | InsecureBasicAuth.java:133:3:133:6 | conn | Insecure basic authentication from $@. | InsecureBasicAuth.java:126:19:126:68 | "http://www.example.com/rest/getuser.do?uid=abcdx" | HTTP url |
|
||||
| InsecureBasicAuth.java:149:3:149:6 | conn | InsecureBasicAuth.java:145:21:145:28 | protocol : String | InsecureBasicAuth.java:149:3:149:6 | conn | Insecure basic authentication from $@. | InsecureBasicAuth.java:145:21:145:28 | protocol | HTTP url |
|
||||
@@ -0,0 +1,164 @@
|
||||
import org.apache.http.RequestLine;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.message.BasicHttpRequest;
|
||||
import org.apache.http.message.BasicRequestLine;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Base64;
|
||||
|
||||
public class InsecureBasicAuth {
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP POST request using string constructor.
|
||||
*/
|
||||
public void testApacheHttpRequest(String username, String password) {
|
||||
String host = "www.example.com";
|
||||
HttpRequestBase post = new HttpPost("http://"+host+"/rest/getuser.do?uid=abcdx");
|
||||
post.setHeader("Accept", "application/json");
|
||||
post.setHeader("Content-type", "application/json");
|
||||
|
||||
String authString = username + ":" + password;
|
||||
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
|
||||
post.addHeader("Authorization", "Basic " + authStringEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP GET request.
|
||||
*/
|
||||
public void testApacheHttpRequest2(String url) throws java.io.IOException {
|
||||
String urlStr = "http://www.example.com:8000/payment/retrieve";
|
||||
HttpGet get = new HttpGet(urlStr);
|
||||
get.setHeader("Accept", "application/json");
|
||||
get.setHeader("Authorization", "Basic " + new String(Base64.getEncoder().encode("admin:test".getBytes())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP POST request using URI create method.
|
||||
*/
|
||||
public void testApacheHttpRequest3(String username, String password) {
|
||||
String uriStr = "http://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
HttpRequestBase post = new HttpPost(URI.create(uriStr));
|
||||
post.setHeader("Accept", "application/json");
|
||||
post.setHeader("Content-type", "application/json");
|
||||
|
||||
String authString = username + ":" + password;
|
||||
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
|
||||
post.addHeader("Authorization", "Basic " + authStringEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP POST request using the URI constructor with one argument.
|
||||
*/
|
||||
public void testApacheHttpRequest4(String username, String password) {
|
||||
String uriStr = "http://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
URI uri = new URI(uriStr);
|
||||
HttpRequestBase post = new HttpPost(uri);
|
||||
post.setHeader("Accept", "application/json");
|
||||
post.setHeader("Content-type", "application/json");
|
||||
|
||||
String authString = username + ":" + password;
|
||||
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
|
||||
post.addHeader("Authorization", "Basic " + authStringEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP POST request using a URI constructor with multiple arguments.
|
||||
*/
|
||||
public void testApacheHttpRequest5(String username, String password) {
|
||||
HttpRequestBase post = new HttpPost(new URI("http", "www.example.com", "/test", "abc=123", null));
|
||||
post.setHeader("Accept", "application/json");
|
||||
post.setHeader("Content-type", "application/json");
|
||||
|
||||
String authString = username + ":" + password;
|
||||
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
|
||||
post.addHeader("Authorization", "Basic " + authStringEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP `BasicHttpRequest` using string constructor.
|
||||
*/
|
||||
public void testApacheHttpRequest6(String username, String password) {
|
||||
String uriStr = "http://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
BasicHttpRequest post = new BasicHttpRequest("POST", uriStr);
|
||||
post.setHeader("Accept", "application/json");
|
||||
post.setHeader("Content-type", "application/json");
|
||||
|
||||
String authString = username + ":" + password;
|
||||
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
|
||||
post.addHeader("Authorization", "Basic " + authStringEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Apache HTTP `BasicHttpRequest` using `RequestLine`.
|
||||
*/
|
||||
public void testApacheHttpRequest7(String username, String password) {
|
||||
String uriStr = "http://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
RequestLine requestLine = new BasicRequestLine("POST", uriStr, null);
|
||||
BasicHttpRequest post = new BasicHttpRequest(requestLine);
|
||||
post.setHeader("Accept", "application/json");
|
||||
post.setHeader("Content-type", "application/json");
|
||||
|
||||
String authString = username + ":" + password;
|
||||
byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes());
|
||||
String authStringEnc = new String(authEncBytes);
|
||||
|
||||
post.addHeader("Authorization", "Basic " + authStringEnc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Java HTTP URL connection using the `URL(String spec)` constructor.
|
||||
*/
|
||||
public void testHttpUrlConnection(String username, String password) {
|
||||
String urlStr = "http://www.example.com/rest/getuser.do?uid=abcdx";
|
||||
String authString = username + ":" + password;
|
||||
String encoding = Base64.getEncoder().encodeToString(authString.getBytes("UTF-8"));
|
||||
URL url = new URL(urlStr);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestProperty("Authorization", "Basic " + encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Java HTTP URL connection using the `URL(String protocol, String host, String file)` constructor.
|
||||
*/
|
||||
public void testHttpUrlConnection2(String username, String password) {
|
||||
String host = "www.example.com";
|
||||
String path = "/rest/getuser.do?uid=abcdx";
|
||||
String protocol = "http";
|
||||
String authString = username + ":" + password;
|
||||
String encoding = Base64.getEncoder().encodeToString(authString.getBytes("UTF-8"));
|
||||
URL url = new URL(protocol, host, path);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestProperty("Authorization", "Basic " + encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic authentication with Java HTTP URL connection using a constructor with private URL.
|
||||
*/
|
||||
public void testHttpUrlConnection3(String username, String password) {
|
||||
String host = "LOCALHOST";
|
||||
String authString = username + ":" + password;
|
||||
String encoding = Base64.getEncoder().encodeToString(authString.getBytes("UTF-8"));
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL("http://"+(((host+"/rest/getuser.do")+"?uid=abcdx"))).openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestProperty("Authorization", "Basic " + encoding);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE/CWE-522/InsecureBasicAuth.ql
|
||||
@@ -0,0 +1 @@
|
||||
// semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/apache-http-4.4.13
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* $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
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* message-header = field-name ":" [ field-value ]
|
||||
* field-name = token
|
||||
* field-value = *( field-content | LWS )
|
||||
* field-content = <the OCTETs making up the field-value
|
||||
* and consisting of either *TEXT or combinations
|
||||
* of token, separators, and quoted-string>
|
||||
* </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 $
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Header {
|
||||
|
||||
String getName();
|
||||
|
||||
String getValue();
|
||||
|
||||
HeaderElement[] getElements() throws ParseException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HeaderElement.java $
|
||||
* $Revision: 569828 $
|
||||
* $Date: 2007-08-26 08:49:38 -0700 (Sun, 26 Aug 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* One element of an HTTP {@link Header header} value.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
*
|
||||
* <!-- empty lines above to avoid 'svn diff' context problems -->
|
||||
* @version $Revision: 569828 $ $Date: 2007-08-26 08:49:38 -0700 (Sun, 26 Aug
|
||||
* 2007) $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HeaderElement {
|
||||
|
||||
String getName();
|
||||
|
||||
String getValue();
|
||||
|
||||
NameValuePair[] getParameters();
|
||||
|
||||
NameValuePair getParameterByName(String name);
|
||||
|
||||
int getParameterCount();
|
||||
|
||||
NameValuePair getParameter(int index);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HeaderElementIterator.java $
|
||||
* $Revision: 584542 $
|
||||
* $Date: 2007-10-14 06:29:34 -0700 (Sun, 14 Oct 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.Iterator;
|
||||
|
||||
/**
|
||||
* A type-safe iterator for {@link HeaderElement HeaderElement} objects.
|
||||
*
|
||||
* @version $Revision: 584542 $
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HeaderElementIterator extends Iterator {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another header element in this
|
||||
* iteration.
|
||||
*
|
||||
* @return <code>true</code> if there is another header element,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Obtains the next header element from this iteration.
|
||||
* This method should only be called while {@link #hasNext hasNext}
|
||||
* is true.
|
||||
*
|
||||
* @return the next header element in this iteration
|
||||
*/
|
||||
HeaderElement nextElement();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HeaderIterator.java $
|
||||
* $Revision: 581981 $
|
||||
* $Date: 2007-10-04 11:26:26 -0700 (Thu, 04 Oct 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.Iterator;
|
||||
|
||||
/**
|
||||
* A type-safe iterator for {@link Header Header} objects.
|
||||
*
|
||||
* @version $Revision: 581981 $
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HeaderIterator extends Iterator {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another header in this iteration.
|
||||
*
|
||||
* @return <code>true</code> if there is another header, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Obtains the next header from this iteration. This method should only be
|
||||
* called while {@link #hasNext hasNext} is true.
|
||||
*
|
||||
* @return the next header in this iteration
|
||||
*/
|
||||
Header nextHeader();
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpEntity.java $
|
||||
* $Revision: 645824 $
|
||||
* $Date: 2008-04-08 03:12:41 -0700 (Tue, 08 Apr 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* An entity that can be sent or received with an HTTP message. Entities can be
|
||||
* found in some {@link HttpEntityEnclosingRequest requests} and in
|
||||
* {@link HttpResponse responses}, where they are optional.
|
||||
* <p>
|
||||
* In some places, the JavaDoc distinguishes three kinds of entities, depending
|
||||
* on where their {@link #getContent content} originates:
|
||||
* <ul>
|
||||
* <li><b>streamed</b>: The content is received from a stream, or generated on
|
||||
* the fly. In particular, this category includes entities being received from a
|
||||
* {@link HttpConnection connection}. {@link #isStreaming Streamed} entities are
|
||||
* generally not {@link #isRepeatable repeatable}.</li>
|
||||
* <li><b>self-contained</b>: The content is in memory or obtained by means that
|
||||
* are independent from a connection or other entity. Self-contained entities
|
||||
* are generally {@link #isRepeatable repeatable}.</li>
|
||||
* <li><b>wrapping</b>: The content is obtained from another entity.</li>
|
||||
* </ul>
|
||||
* This distinction is important for connection management with incoming
|
||||
* entities. For entities that are created by an application and only sent using
|
||||
* the HTTP components framework, the difference between streamed and
|
||||
* self-contained is of little importance. In that case, it is suggested to
|
||||
* consider non-repeatable entities as streamed, and those that are repeatable
|
||||
* (without a huge effort) as self-contained.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 645824 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HttpEntity {
|
||||
|
||||
/**
|
||||
* Tells if the entity is capable to produce its data more than once. A
|
||||
* repeatable entity's getContent() and writeTo(OutputStream) methods can be
|
||||
* called more than once whereas a non-repeatable entity's can not.
|
||||
*
|
||||
* @return true if the entity is repeatable, false otherwise.
|
||||
*/
|
||||
boolean isRepeatable();
|
||||
|
||||
/**
|
||||
* Tells about chunked encoding for this entity. The primary purpose of this
|
||||
* method is to indicate whether chunked encoding should be used when the entity
|
||||
* is sent. For entities that are received, it can also indicate whether the
|
||||
* entity was received with chunked encoding. <br/>
|
||||
* The behavior of wrapping entities is implementation dependent, but should
|
||||
* respect the primary purpose.
|
||||
*
|
||||
* @return <code>true</code> if chunked encoding is preferred for this entity,
|
||||
* or <code>false</code> if it is not
|
||||
*/
|
||||
boolean isChunked();
|
||||
|
||||
/**
|
||||
* Tells the length of the content, if known.
|
||||
*
|
||||
* @return the number of bytes of the content, or a negative number if unknown.
|
||||
* If the content length is known but exceeds
|
||||
* {@link java.lang.Long#MAX_VALUE Long.MAX_VALUE}, a negative number is
|
||||
* returned.
|
||||
*/
|
||||
long getContentLength();
|
||||
|
||||
/**
|
||||
* Obtains the Content-Type header, if known. This is the header that should be
|
||||
* used when sending the entity, or the one that was received with the entity.
|
||||
* It can include a charset attribute.
|
||||
*
|
||||
* @return the Content-Type header for this entity, or <code>null</code> if the
|
||||
* content type is unknown
|
||||
*/
|
||||
Header getContentType();
|
||||
|
||||
/**
|
||||
* Obtains the Content-Encoding header, if known. This is the header that should
|
||||
* be used when sending the entity, or the one that was received with the
|
||||
* entity. Wrapping entities that modify the content encoding should adjust this
|
||||
* header accordingly.
|
||||
*
|
||||
* @return the Content-Encoding header for this entity, or <code>null</code> if
|
||||
* the content encoding is unknown
|
||||
*/
|
||||
Header getContentEncoding();
|
||||
|
||||
/**
|
||||
* Creates a new InputStream object of the entity. It is a programming error to
|
||||
* return the same InputStream object more than once. Entities that are not
|
||||
* {@link #isRepeatable repeatable} will throw an exception if this method is
|
||||
* called multiple times.
|
||||
*
|
||||
* @return a new input stream that returns the entity data.
|
||||
*
|
||||
* @throws IOException if the stream could not be created
|
||||
* @throws IllegalStateException if this entity is not repeatable and the stream
|
||||
* has already been obtained previously
|
||||
*/
|
||||
InputStream getContent() throws IOException, IllegalStateException;
|
||||
|
||||
/**
|
||||
* Writes the entity content to the output stream.
|
||||
*
|
||||
* @param outstream the output stream to write entity content to
|
||||
*
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
void writeTo(OutputStream outstream) throws IOException;
|
||||
|
||||
/**
|
||||
* Tells whether this entity depends on an underlying stream. Streamed entities
|
||||
* should return <code>true</code> until the content has been consumed,
|
||||
* <code>false</code> afterwards. Self-contained entities should return
|
||||
* <code>false</code>. Wrapping entities should delegate this call to the
|
||||
* wrapped entity. <br/>
|
||||
* The content of a streamed entity is consumed when the stream returned by
|
||||
* {@link #getContent getContent} has been read to EOF, or after
|
||||
* {@link #consumeContent consumeContent} has been called. If a streamed entity
|
||||
* can not detect whether the stream has been read to EOF, it should return
|
||||
* <code>true</code> until {@link #consumeContent consumeContent} is called.
|
||||
*
|
||||
* @return <code>true</code> if the entity content is streamed and not yet
|
||||
* consumed, <code>false</code> otherwise
|
||||
*/
|
||||
boolean isStreaming(); // don't expect an exception here
|
||||
|
||||
/**
|
||||
* TODO: The name of this method is misnomer. It will be renamed to #finish() in
|
||||
* the next major release. <br/>
|
||||
* This method is called to indicate that the content of this entity is no
|
||||
* longer required. All entity implementations are expected to release all
|
||||
* allocated resources as a result of this method invocation. Content streaming
|
||||
* entities are also expected to dispose of the remaining content, if any.
|
||||
* Wrapping entities should delegate this call to the wrapped entity. <br/>
|
||||
* This method is of particular importance for entities being received from a
|
||||
* {@link HttpConnection connection}. The entity needs to be consumed completely
|
||||
* in order to re-use the connection with keep-alive.
|
||||
*
|
||||
* @throws IOException if an I/O error occurs. This indicates that connection
|
||||
* keep-alive is not possible.
|
||||
*/
|
||||
void consumeContent() throws IOException;
|
||||
|
||||
} // interface HttpEntity
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* $Header: $
|
||||
* $Revision: 618017 $
|
||||
* $Date: 2008-02-03 08:42:22 -0800 (Sun, 03 Feb 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* A request with an entity.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 618017 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HttpEntityEnclosingRequest extends HttpRequest {
|
||||
|
||||
/**
|
||||
* Tells if this request should use the expect-continue handshake. The expect
|
||||
* continue handshake gives the server a chance to decide whether to accept the
|
||||
* entity enclosing request before the possibly lengthy entity is sent across
|
||||
* the wire.
|
||||
*
|
||||
* @return true if the expect continue handshake should be used, false if not.
|
||||
*/
|
||||
boolean expectContinue();
|
||||
|
||||
/**
|
||||
* Hands the entity to the request.
|
||||
*
|
||||
* @param entity the entity to send.
|
||||
*/
|
||||
void setEntity(HttpEntity entity);
|
||||
|
||||
HttpEntity getEntity();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpMessage.java $
|
||||
* $Revision: 610823 $
|
||||
* $Date: 2008-01-10 07:53:53 -0800 (Thu, 10 Jan 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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 org.apache.http.params.HttpParams;
|
||||
|
||||
/**
|
||||
* A generic HTTP message.
|
||||
* Holds what is common between requests and responses.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 610823 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HttpMessage {
|
||||
|
||||
/**
|
||||
* Returns the protocol version this message is compatible with.
|
||||
*/
|
||||
ProtocolVersion getProtocolVersion();
|
||||
|
||||
/**
|
||||
* Checks if a certain header is present in this message. Header values are
|
||||
* ignored.
|
||||
*
|
||||
* @param name the header name to check for.
|
||||
* @return true if at least one header with this name is present.
|
||||
*/
|
||||
boolean containsHeader(String name);
|
||||
|
||||
/**
|
||||
* Returns all the headers with a specified name of this message. Header values
|
||||
* are ignored. Headers are orderd in the sequence they will be sent over a
|
||||
* connection.
|
||||
*
|
||||
* @param name the name of the headers to return.
|
||||
* @return the headers whose name property equals <code>name</code>.
|
||||
*/
|
||||
Header[] getHeaders(String name);
|
||||
|
||||
/**
|
||||
* Returns the first header with a specified name of this message. Header
|
||||
* values are ignored. If there is more than one matching header in the
|
||||
* message the first element of {@link #getHeaders(String)} is returned.
|
||||
* If there is no matching header in the message <code>null</code> is
|
||||
* returned.
|
||||
*
|
||||
* @param name the name of the header to return.
|
||||
* @return the first header whose name property equals <code>name</code>
|
||||
* or <code>null</code> if no such header could be found.
|
||||
*/
|
||||
Header getFirstHeader(String name);
|
||||
|
||||
/**
|
||||
* Returns the last header with a specified name of this message. Header values
|
||||
* are ignored. If there is more than one matching header in the message the
|
||||
* last element of {@link #getHeaders(String)} is returned. If there is no
|
||||
* matching header in the message <code>null</code> is returned.
|
||||
*
|
||||
* @param name the name of the header to return.
|
||||
* @return the last header whose name property equals <code>name</code>.
|
||||
* or <code>null</code> if no such header could be found.
|
||||
*/
|
||||
Header getLastHeader(String name);
|
||||
|
||||
/**
|
||||
* Returns all the headers of this message. Headers are orderd in the sequence
|
||||
* they will be sent over a connection.
|
||||
*
|
||||
* @return all the headers of this message
|
||||
*/
|
||||
Header[] getAllHeaders();
|
||||
|
||||
/**
|
||||
* Adds a header to this message. The header will be appended to the end of
|
||||
* the list.
|
||||
*
|
||||
* @param header the header to append.
|
||||
*/
|
||||
void addHeader(Header header);
|
||||
|
||||
/**
|
||||
* Adds a header to this message. The header will be appended to the end of
|
||||
* the list.
|
||||
*
|
||||
* @param name the name of the header.
|
||||
* @param value the value of the header.
|
||||
*/
|
||||
void addHeader(String name, String value);
|
||||
|
||||
/**
|
||||
* Overwrites the first header with the same name. The new header will be appended to
|
||||
* the end of the list, if no header with the given name can be found.
|
||||
*
|
||||
* @param header the header to set.
|
||||
*/
|
||||
void setHeader(Header header);
|
||||
|
||||
/**
|
||||
* Overwrites the first header with the same name. The new header will be appended to
|
||||
* the end of the list, if no header with the given name can be found.
|
||||
*
|
||||
* @param name the name of the header.
|
||||
* @param value the value of the header.
|
||||
*/
|
||||
void setHeader(String name, String value);
|
||||
|
||||
/**
|
||||
* Overwrites all the headers in the message.
|
||||
*
|
||||
* @param headers the array of headers to set.
|
||||
*/
|
||||
void setHeaders(Header[] headers);
|
||||
|
||||
/**
|
||||
* Removes a header from this message.
|
||||
*
|
||||
* @param header the header to remove.
|
||||
*/
|
||||
void removeHeader(Header header);
|
||||
|
||||
/**
|
||||
* Removes all headers with a certain name from this message.
|
||||
*
|
||||
* @param name The name of the headers to remove.
|
||||
*/
|
||||
void removeHeaders(String name);
|
||||
|
||||
/**
|
||||
* Returns an iterator of all the headers.
|
||||
*
|
||||
* @return Iterator that returns Header objects in the sequence they are
|
||||
* sent over a connection.
|
||||
*/
|
||||
HeaderIterator headerIterator();
|
||||
|
||||
/**
|
||||
* Returns an iterator of the headers with a given name.
|
||||
*
|
||||
* @param name the name of the headers over which to iterate, or
|
||||
* <code>null</code> for all headers
|
||||
*
|
||||
* @return Iterator that returns Header objects with the argument name
|
||||
* in the sequence they are sent over a connection.
|
||||
*/
|
||||
HeaderIterator headerIterator(String name);
|
||||
|
||||
/**
|
||||
* Returns the parameters effective for this message as set by
|
||||
* {@link #setParams(HttpParams)}.
|
||||
*/
|
||||
HttpParams getParams();
|
||||
|
||||
/**
|
||||
* Provides parameters to be used for the processing of this message.
|
||||
* @param params the parameters
|
||||
*/
|
||||
void setParams(HttpParams params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpRequest.java $
|
||||
* $Revision: 528428 $
|
||||
* $Date: 2007-04-13 03:26:04 -0700 (Fri, 13 Apr 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* An HTTP request.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 528428 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HttpRequest extends HttpMessage {
|
||||
|
||||
/**
|
||||
* Returns the request line of this request.
|
||||
*
|
||||
* @return the request line.
|
||||
*/
|
||||
RequestLine getRequestLine();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/NameValuePair.java $
|
||||
* $Revision: 496070 $
|
||||
* $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* A simple class encapsulating an attribute/value pair.
|
||||
* <p>
|
||||
* This class comforms to the generic grammar and formatting rules outlined in
|
||||
* the <a href=
|
||||
* "http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2">Section
|
||||
* 2.2</a> and <a href=
|
||||
* "http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6">Section
|
||||
* 3.6</a> of <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.txt">RFC
|
||||
* 2616</a>
|
||||
* </p>
|
||||
* <h>2.2 Basic Rules</h>
|
||||
* <p>
|
||||
* The following rules are used throughout this specification to describe basic
|
||||
* parsing constructs. The US-ASCII coded character set is defined by ANSI
|
||||
* X3.4-1986.
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* OCTET = <any 8-bit sequence of data>
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
* UPALPHA = <any US-ASCII uppercase letter "A".."Z">
|
||||
* LOALPHA = <any US-ASCII lowercase letter "a".."z">
|
||||
* ALPHA = UPALPHA | LOALPHA
|
||||
* DIGIT = <any US-ASCII digit "0".."9">
|
||||
* CTL = <any US-ASCII control character
|
||||
* (octets 0 - 31) and DEL (127)>
|
||||
* CR = <US-ASCII CR, carriage return (13)>
|
||||
* LF = <US-ASCII LF, linefeed (10)>
|
||||
* SP = <US-ASCII SP, space (32)>
|
||||
* HT = <US-ASCII HT, horizontal-tab (9)>
|
||||
* <"> = <US-ASCII double-quote mark (34)>
|
||||
* </pre>
|
||||
* <p>
|
||||
* Many HTTP/1.1 header field values consist of words separated by LWS or
|
||||
* special characters. These special characters MUST be in a quoted string to be
|
||||
* used within a parameter value (as defined in section 3.6).
|
||||
* <p>
|
||||
*
|
||||
* <pre>
|
||||
* token = 1*<any CHAR except CTLs or separators>
|
||||
* separators = "(" | ")" | "<" | ">" | "@"
|
||||
* | "," | ";" | ":" | "\" | <">
|
||||
* | "/" | "[" | "]" | "?" | "="
|
||||
* | "{" | "}" | SP | HT
|
||||
* </pre>
|
||||
* <p>
|
||||
* A string of text is parsed as a single word if it is quoted using
|
||||
* double-quote marks.
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
|
||||
* qdtext = <any TEXT except <">>
|
||||
* </pre>
|
||||
* <p>
|
||||
* The backslash character ("\") MAY be used as a single-character quoting
|
||||
* mechanism only within quoted-string and comment constructs.
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* quoted-pair = "\" CHAR
|
||||
* </pre>
|
||||
*
|
||||
* <h>3.6 Transfer Codings</h>
|
||||
* <p>
|
||||
* Parameters are in the form of attribute/value pairs.
|
||||
* </p>
|
||||
*
|
||||
* <pre>
|
||||
* parameter = attribute "=" value
|
||||
* attribute = token
|
||||
* value = token | quoted-string
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.com">Oleg Kalnichevski</a>
|
||||
*
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface NameValuePair {
|
||||
|
||||
String getName();
|
||||
|
||||
String getValue();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ParseException.java $
|
||||
* $Revision: 609106 $
|
||||
* $Date: 2008-01-05 01:15:42 -0800 (Sat, 05 Jan 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Indicates a parse error. Parse errors when receiving a message will typically
|
||||
* trigger {@link ProtocolException}. Parse errors that do not occur during
|
||||
* protocol execution may be handled differently. This is an unchecked
|
||||
* exceptions, since there are cases where the data to be parsed has been
|
||||
* generated and is therefore known to be parseable.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ParseException extends RuntimeException {
|
||||
/**
|
||||
* Creates a {@link ParseException} without details.
|
||||
*/
|
||||
public ParseException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link ParseException} with a detail message.
|
||||
*
|
||||
* @param message the exception detail message, or <code>null</code>
|
||||
*/
|
||||
public ParseException(String message) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProtocolVersion.java $
|
||||
* $Revision: 609106 $
|
||||
* $Date: 2008-01-05 01:15:42 -0800 (Sat, 05 Jan 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a protocol version, as specified in RFC 2616. RFC 2616 specifies
|
||||
* only HTTP versions, like "HTTP/1.1" and "HTTP/1.0". RFC 3261 specifies a
|
||||
* message format that is identical to HTTP except for the protocol name. It
|
||||
* defines a protocol version "SIP/2.0". There are some nitty-gritty differences
|
||||
* between the interpretation of versions in HTTP and SIP. In those cases, HTTP
|
||||
* takes precedence.
|
||||
* <p>
|
||||
* This class defines a protocol version as a combination of protocol name,
|
||||
* major version number, and minor version number. Note that {@link #equals} and
|
||||
* {@link #hashCode} are defined as final here, they cannot be overridden in
|
||||
* derived classes.
|
||||
*
|
||||
* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
|
||||
* @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
|
||||
*
|
||||
* @version $Revision: 609106 $
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ProtocolVersion implements Serializable, Cloneable {
|
||||
/**
|
||||
* Create a protocol version designator.
|
||||
*
|
||||
* @param protocol the name of the protocol, for example "HTTP"
|
||||
* @param major the major version number of the protocol
|
||||
* @param minor the minor version number of the protocol
|
||||
*/
|
||||
public ProtocolVersion(String protocol, int major, int minor) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the protocol.
|
||||
*
|
||||
* @return the protocol name
|
||||
*/
|
||||
public final String getProtocol() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the major version number of the protocol.
|
||||
*
|
||||
* @return the major version number.
|
||||
*/
|
||||
public final int getMajor() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minor version number of the HTTP protocol.
|
||||
*
|
||||
* @return the minor version number.
|
||||
*/
|
||||
public final int getMinor() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a specific version of this protocol. This can be used by derived
|
||||
* classes to instantiate themselves instead of the base class, and to define
|
||||
* constants for commonly used versions. <br/>
|
||||
* The default implementation in this class returns <code>this</code> if the
|
||||
* version matches, and creates a new {@link ProtocolVersion} otherwise.
|
||||
*
|
||||
* @param major the major version
|
||||
* @param minor the minor version
|
||||
*
|
||||
* @return a protocol version with the same protocol name and the argument
|
||||
* version
|
||||
*/
|
||||
public ProtocolVersion forVersion(int major, int minor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a hash code consistent with {@link #equals}.
|
||||
*
|
||||
* @return the hashcode of this protocol version
|
||||
*/
|
||||
public final int hashCode() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks equality of this protocol version with an object. The object is equal
|
||||
* if it is a protocl version with the same protocol name, major version number,
|
||||
* and minor version number. The specific class of the object is <i>not</i>
|
||||
* relevant, instances of derived classes with identical attributes are equal to
|
||||
* instances of the base class and vice versa.
|
||||
*
|
||||
* @param obj the object to compare with
|
||||
*
|
||||
* @return <code>true</code> if the argument is the same protocol version,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this protocol can be compared to another one. Only protocol
|
||||
* versions with the same protocol name can be {@link #compareToVersion
|
||||
* compared}.
|
||||
*
|
||||
* @param that the protocol version to consider
|
||||
*
|
||||
* @return <code>true</code> if {@link #compareToVersion compareToVersion} can
|
||||
* be called with the argument, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isComparable(ProtocolVersion that) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this protocol version with another one. Only protocol versions with
|
||||
* the same protocol name can be compared. This method does <i>not</i> define a
|
||||
* total ordering, as it would be required for {@link java.lang.Comparable}.
|
||||
*
|
||||
* @param that the protocl version to compare with
|
||||
*
|
||||
* @return a negative integer, zero, or a positive integer as this version is
|
||||
* less than, equal to, or greater than the argument version.
|
||||
*
|
||||
* @throws IllegalArgumentException if the argument has a different protocol
|
||||
* name than this object, or if the argument is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public int compareToVersion(ProtocolVersion that) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if this protocol version is greater or equal to the given one.
|
||||
*
|
||||
* @param version the version against which to check this version
|
||||
*
|
||||
* @return <code>true</code> if this protocol version is {@link #isComparable
|
||||
* comparable} to the argument and {@link #compareToVersion compares} as
|
||||
* greater or equal, <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean greaterEquals(ProtocolVersion version) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if this protocol version is less or equal to the given one.
|
||||
*
|
||||
* @param version the version against which to check this version
|
||||
*
|
||||
* @return <code>true</code> if this protocol version is {@link #isComparable
|
||||
* comparable} to the argument and {@link #compareToVersion compares} as
|
||||
* less or equal, <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean lessEquals(ProtocolVersion version) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this protocol version to a string.
|
||||
*
|
||||
* @return a protocol version string, like "HTTP/1.1"
|
||||
*/
|
||||
public String toString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/RequestLine.java $
|
||||
* $Revision: 573864 $
|
||||
* $Date: 2007-09-08 08:53:25 -0700 (Sat, 08 Sep 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The first line of an {@link HttpRequest HttpRequest}. It contains the method,
|
||||
* URI, and HTTP version of the request. For details, see RFC 2616.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 573864 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface RequestLine {
|
||||
|
||||
String getMethod();
|
||||
|
||||
ProtocolVersion getProtocolVersion();
|
||||
|
||||
String getUri();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java $
|
||||
* $Revision: 674186 $
|
||||
* $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.client.methods;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpEntityEnclosingRequest;
|
||||
|
||||
/**
|
||||
* Basic implementation of an HTTP request that can be modified.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 674186 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class HttpEntityEnclosingRequestBase extends HttpRequestBase implements HttpEntityEnclosingRequest {
|
||||
|
||||
public HttpEntityEnclosingRequestBase() {
|
||||
}
|
||||
|
||||
public HttpEntity getEntity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEntity(final HttpEntity entity) {
|
||||
}
|
||||
|
||||
public boolean expectContinue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpGet.java $
|
||||
* $Revision: 664505 $
|
||||
* $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.client.methods;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* HTTP GET method.
|
||||
* <p>
|
||||
* The HTTP GET method is defined in section 9.3 of
|
||||
* <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: <blockquote> The
|
||||
* GET method means retrieve whatever information (in the form of an entity) is
|
||||
* identified by the Request-URI. If the Request-URI refers to a data-producing
|
||||
* process, it is the produced data which shall be returned as the entity in the
|
||||
* response and not the source text of the process, unless that text happens to
|
||||
* be the output of the process. </blockquote>
|
||||
* </p>
|
||||
* <p>
|
||||
* GetMethods will follow redirect requests from the http server by default.
|
||||
* This behavour can be disabled by calling setFollowRedirects(false).
|
||||
* </p>
|
||||
*
|
||||
* @version $Revision: 664505 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class HttpGet extends HttpRequestBase {
|
||||
public final static String METHOD_NAME = "GET";
|
||||
|
||||
public HttpGet() {
|
||||
}
|
||||
|
||||
public HttpGet(final URI uri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the uri is invalid.
|
||||
*/
|
||||
public HttpGet(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpPost.java $
|
||||
* $Revision: 664505 $
|
||||
* $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.client.methods;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* HTTP POST method.
|
||||
* <p>
|
||||
* The HTTP POST method is defined in section 9.5 of
|
||||
* <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: <blockquote> The
|
||||
* POST method is used to request that the origin server accept the entity
|
||||
* enclosed in the request as a new subordinate of the resource identified by
|
||||
* the Request-URI in the Request-Line. POST is designed to allow a uniform
|
||||
* method to cover the following functions:
|
||||
* <ul>
|
||||
* <li>Annotation of existing resources</li>
|
||||
* <li>Posting a message to a bulletin board, newsgroup, mailing list, or
|
||||
* similar group of articles</li>
|
||||
* <li>Providing a block of data, such as the result of submitting a form, to a
|
||||
* data-handling process</li>
|
||||
* <li>Extending a database through an append operation</li>
|
||||
* </ul>
|
||||
* </blockquote>
|
||||
* </p>
|
||||
*
|
||||
* @version $Revision: 664505 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class HttpPost extends HttpEntityEnclosingRequestBase {
|
||||
public final static String METHOD_NAME = "POST";
|
||||
|
||||
public HttpPost() {
|
||||
}
|
||||
|
||||
public HttpPost(final URI uri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the uri is invalid.
|
||||
*/
|
||||
public HttpPost(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpPut.java $
|
||||
* $Revision: 664505 $
|
||||
* $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.client.methods;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* HTTP PUT method.
|
||||
* <p>
|
||||
* The HTTP PUT method is defined in section 9.6 of
|
||||
* <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>: <blockquote> The
|
||||
* PUT method requests that the enclosed entity be stored under the supplied
|
||||
* Request-URI. If the Request-URI refers to an already existing resource, the
|
||||
* enclosed entity SHOULD be considered as a modified version of the one
|
||||
* residing on the origin server. </blockquote>
|
||||
* </p>
|
||||
*
|
||||
* @version $Revision: 664505 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class HttpPut extends HttpEntityEnclosingRequestBase {
|
||||
public final static String METHOD_NAME = "PUT";
|
||||
|
||||
public HttpPut() {
|
||||
}
|
||||
|
||||
public HttpPut(final URI uri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the uri is invalid.
|
||||
*/
|
||||
public HttpPut(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpRequestBase.java $
|
||||
* $Revision: 674186 $
|
||||
* $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.client.methods;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.http.message.AbstractHttpMessage;
|
||||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.RequestLine;
|
||||
|
||||
/**
|
||||
* Basic implementation of an HTTP request that can be modified.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 674186 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class HttpRequestBase extends AbstractHttpMessage {
|
||||
public HttpRequestBase() {
|
||||
}
|
||||
|
||||
public abstract String getMethod();
|
||||
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URI getURI() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestLine getRequestLine() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setURI(final URI uri) {
|
||||
}
|
||||
|
||||
public void abort() {
|
||||
}
|
||||
|
||||
public boolean isAborted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add method from `org.apache.http.HttpMessage`
|
||||
public void addHeader(String name, String value) {
|
||||
}
|
||||
|
||||
// Add method from `org.apache.http.HttpMessage`
|
||||
public void setHeader(String name, String value) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/AbstractHttpMessage.java $
|
||||
* $Revision: 620287 $
|
||||
* $Date: 2008-02-10 07:15:53 -0800 (Sun, 10 Feb 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.util.Iterator;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HeaderIterator;
|
||||
import org.apache.http.HttpMessage;
|
||||
import org.apache.http.params.HttpParams;
|
||||
|
||||
/**
|
||||
* Basic implementation of an HTTP message that can be modified.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 620287 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractHttpMessage implements HttpMessage {
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public boolean containsHeader(String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public Header[] getHeaders(final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public Header getFirstHeader(final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public Header getLastHeader(final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public Header[] getAllHeaders() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void addHeader(final Header header) {
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void addHeader(final String name, final String value) {
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void setHeader(final Header header) {
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void setHeader(final String name, final String value) {
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void setHeaders(final Header[] headers) {
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void removeHeader(final Header header) {
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void removeHeaders(final String name) {
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public HeaderIterator headerIterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public HeaderIterator headerIterator(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public HttpParams getParams() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// non-javadoc, see interface HttpMessage
|
||||
public void setParams(final HttpParams params) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java $
|
||||
* $Revision: 618017 $
|
||||
* $Date: 2008-02-03 08:42:22 -0800 (Sun, 03 Feb 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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 org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpEntityEnclosingRequest;
|
||||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.RequestLine;
|
||||
|
||||
/**
|
||||
* Basic implementation of a request with an entity that can be modified.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 618017 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BasicHttpEntityEnclosingRequest extends BasicHttpRequest implements HttpEntityEnclosingRequest {
|
||||
public BasicHttpEntityEnclosingRequest(final String method, final String uri) {
|
||||
super(method, uri);
|
||||
}
|
||||
|
||||
public BasicHttpEntityEnclosingRequest(final String method, final String uri, final ProtocolVersion ver) {
|
||||
super(method, uri, ver);
|
||||
}
|
||||
|
||||
public BasicHttpEntityEnclosingRequest(final RequestLine requestline) {
|
||||
super(requestline);
|
||||
}
|
||||
|
||||
public HttpEntity getEntity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEntity(final HttpEntity entity) {
|
||||
}
|
||||
|
||||
public boolean expectContinue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHttpRequest.java $
|
||||
* $Revision: 573864 $
|
||||
* $Date: 2007-09-08 08:53:25 -0700 (Sat, 08 Sep 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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 org.apache.http.HttpRequest;
|
||||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.RequestLine;
|
||||
|
||||
/**
|
||||
* Basic implementation of an HTTP request that can be modified.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 573864 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BasicHttpRequest extends AbstractHttpMessage implements HttpRequest {
|
||||
public BasicHttpRequest(final String method, final String uri) {
|
||||
}
|
||||
|
||||
public BasicHttpRequest(final String method, final String uri, final ProtocolVersion ver) {
|
||||
}
|
||||
|
||||
public BasicHttpRequest(final RequestLine requestline) {
|
||||
}
|
||||
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestLine getRequestLine() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Add method from `org.apache.http.HttpMessage`
|
||||
public void addHeader(String name, String value) {
|
||||
}
|
||||
|
||||
// Add method from `org.apache.http.HttpMessage`
|
||||
public void setHeader(String name, String value) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicRequestLine.java $
|
||||
* $Revision: 604625 $
|
||||
* $Date: 2007-12-16 06:11:11 -0800 (Sun, 16 Dec 2007) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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 org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.RequestLine;
|
||||
|
||||
/**
|
||||
* The first line of an {@link org.apache.http.HttpRequest HttpRequest}.
|
||||
* It contains the method, URI, and HTTP version of the request.
|
||||
* For details, see RFC 2616.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
*
|
||||
* <!-- empty lines above to avoid 'svn diff' context problems -->
|
||||
* @version $Revision: 604625 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BasicRequestLine implements RequestLine, Cloneable {
|
||||
public BasicRequestLine(final String method, final String uri, final ProtocolVersion version) {
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java $
|
||||
* $Revision: 610763 $
|
||||
* $Date: 2008-01-10 04:01:13 -0800 (Thu, 10 Jan 2008) $
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.params;
|
||||
/**
|
||||
* Represents a collection of HTTP protocol and framework parameters.
|
||||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*
|
||||
* @version $Revision: 610763 $
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HttpParams {
|
||||
/**
|
||||
* Obtains the value of the given parameter.
|
||||
*
|
||||
* @param name the parent name.
|
||||
*
|
||||
* @return an object that represents the value of the parameter,
|
||||
* <code>null</code> if the parameter is not set or if it
|
||||
* is explicitly set to <code>null</code>
|
||||
*
|
||||
* @see #setParameter(String, Object)
|
||||
*/
|
||||
Object getParameter(String name);
|
||||
/**
|
||||
* Assigns the value to the parameter with the given name.
|
||||
*
|
||||
* @param name parameter name
|
||||
* @param value parameter value
|
||||
*/
|
||||
HttpParams setParameter(String name, Object value);
|
||||
/**
|
||||
* Creates a copy of these parameters.
|
||||
*
|
||||
* @return a new set of parameters holding the same values as this one
|
||||
*/
|
||||
HttpParams copy();
|
||||
|
||||
/**
|
||||
* Removes the parameter with the specified name.
|
||||
*
|
||||
* @param name parameter name
|
||||
*
|
||||
* @return true if the parameter existed and has been removed, false else.
|
||||
*/
|
||||
boolean removeParameter(String name);
|
||||
/**
|
||||
* Returns a {@link Long} parameter value with the given name.
|
||||
* If the parameter is not explicitly set, the default value is returned.
|
||||
*
|
||||
* @param name the parent name.
|
||||
* @param defaultValue the default value.
|
||||
*
|
||||
* @return a {@link Long} that represents the value of the parameter.
|
||||
*
|
||||
* @see #setLongParameter(String, long)
|
||||
*/
|
||||
long getLongParameter(String name, long defaultValue);
|
||||
/**
|
||||
* Assigns a {@link Long} to the parameter with the given name
|
||||
*
|
||||
* @param name parameter name
|
||||
* @param value parameter value
|
||||
*/
|
||||
HttpParams setLongParameter(String name, long value);
|
||||
/**
|
||||
* Returns an {@link Integer} parameter value with the given name.
|
||||
* If the parameter is not explicitly set, the default value is returned.
|
||||
*
|
||||
* @param name the parent name.
|
||||
* @param defaultValue the default value.
|
||||
*
|
||||
* @return a {@link Integer} that represents the value of the parameter.
|
||||
*
|
||||
* @see #setIntParameter(String, int)
|
||||
*/
|
||||
int getIntParameter(String name, int defaultValue);
|
||||
/**
|
||||
* Assigns an {@link Integer} to the parameter with the given name
|
||||
*
|
||||
* @param name parameter name
|
||||
* @param value parameter value
|
||||
*/
|
||||
HttpParams setIntParameter(String name, int value);
|
||||
/**
|
||||
* Returns a {@link Double} parameter value with the given name.
|
||||
* If the parameter is not explicitly set, the default value is returned.
|
||||
*
|
||||
* @param name the parent name.
|
||||
* @param defaultValue the default value.
|
||||
*
|
||||
* @return a {@link Double} that represents the value of the parameter.
|
||||
*
|
||||
* @see #setDoubleParameter(String, double)
|
||||
*/
|
||||
double getDoubleParameter(String name, double defaultValue);
|
||||
/**
|
||||
* Assigns a {@link Double} to the parameter with the given name
|
||||
*
|
||||
* @param name parameter name
|
||||
* @param value parameter value
|
||||
*/
|
||||
HttpParams setDoubleParameter(String name, double value);
|
||||
/**
|
||||
* Returns a {@link Boolean} parameter value with the given name.
|
||||
* If the parameter is not explicitly set, the default value is returned.
|
||||
*
|
||||
* @param name the parent name.
|
||||
* @param defaultValue the default value.
|
||||
*
|
||||
* @return a {@link Boolean} that represents the value of the parameter.
|
||||
*
|
||||
* @see #setBooleanParameter(String, boolean)
|
||||
*/
|
||||
boolean getBooleanParameter(String name, boolean defaultValue);
|
||||
/**
|
||||
* Assigns a {@link Boolean} to the parameter with the given name
|
||||
*
|
||||
* @param name parameter name
|
||||
* @param value parameter value
|
||||
*/
|
||||
HttpParams setBooleanParameter(String name, boolean value);
|
||||
/**
|
||||
* Checks if a boolean parameter is set to <code>true</code>.
|
||||
*
|
||||
* @param name parameter name
|
||||
*
|
||||
* @return <tt>true</tt> if the parameter is set to value <tt>true</tt>,
|
||||
* <tt>false</tt> if it is not set or set to <code>false</code>
|
||||
*/
|
||||
boolean isParameterTrue(String name);
|
||||
/**
|
||||
* Checks if a boolean parameter is not set or <code>false</code>.
|
||||
*
|
||||
* @param name parameter name
|
||||
*
|
||||
* @return <tt>true</tt> if the parameter is either not set or
|
||||
* set to value <tt>false</tt>,
|
||||
* <tt>false</tt> if it is set to <code>true</code>
|
||||
*/
|
||||
boolean isParameterFalse(String name);
|
||||
}
|
||||
Reference in New Issue
Block a user