mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Add missing tests, add additional models revealed missing in the process, and add stubs to support them all.
This commit is contained in:
@@ -118,7 +118,9 @@ private class ApacheHttpOpenUrlSink extends SinkModelCsv {
|
||||
"org.apache.http.client.methods;RequestBuilder;false;put;;;Argument[0];open-url",
|
||||
"org.apache.http.client.methods;RequestBuilder;false;options;;;Argument[0];open-url",
|
||||
"org.apache.http.client.methods;RequestBuilder;false;head;;;Argument[0];open-url",
|
||||
"org.apache.http.client.methods;RequestBuilder;false;delete;;;Argument[0];open-url"
|
||||
"org.apache.http.client.methods;RequestBuilder;false;delete;;;Argument[0];open-url",
|
||||
"org.apache.http.client.methods;RequestBuilder;false;trace;;;Argument[0];open-url",
|
||||
"org.apache.http.client.methods;RequestBuilder;false;patch;;;Argument[0];open-url"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,16 +33,19 @@ private class UrlOpenSink extends SinkModelCsv {
|
||||
override predicate row(string row) {
|
||||
row =
|
||||
[
|
||||
"org.springframework.web.client;RestTemplate;false;delete;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;doExecute;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;postForEntity;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;postForLocation;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;postForObject;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;put;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;exchange;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;execute;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;getForEntity;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;getForObject;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;patchForObject;;;Argument[0];open-url"
|
||||
"org.springframework.web.client;RestTemplate;false;headForHeaders;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;optionsForAllow;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;patchForObject;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;postForEntity;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;postForLocation;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;postForObject;;;Argument[0];open-url",
|
||||
"org.springframework.web.client;RestTemplate;false;put;;;Argument[0];open-url"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,17 @@ import java.net.Proxy.Type;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpHead;
|
||||
import org.apache.http.client.methods.HttpOptions;
|
||||
import org.apache.http.client.methods.HttpTrace;
|
||||
import org.apache.http.client.methods.HttpPatch;
|
||||
import org.apache.http.client.methods.RequestBuilder;
|
||||
import org.apache.http.message.BasicHttpRequest;
|
||||
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
|
||||
import org.apache.http.message.BasicRequestLine;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -67,6 +78,33 @@ public class RequestForgery2 extends HttpServlet {
|
||||
HttpGet httpGet = new HttpGet(uri);
|
||||
HttpGet httpGet2 = new HttpGet();
|
||||
httpGet2.setURI(uri2);
|
||||
|
||||
new HttpHead(uri);
|
||||
new HttpPost(uri);
|
||||
new HttpPut(uri);
|
||||
new HttpDelete(uri);
|
||||
new HttpOptions(uri);
|
||||
new HttpTrace(uri);
|
||||
new HttpPatch(uri);
|
||||
|
||||
new BasicHttpRequest(new BasicRequestLine("GET", uri2.toString(), null));
|
||||
new BasicHttpRequest("GET", uri2.toString());
|
||||
new BasicHttpRequest("GET", uri2.toString(), null);
|
||||
|
||||
new BasicHttpEntityEnclosingRequest(new BasicRequestLine("GET", uri2.toString(), null));
|
||||
new BasicHttpEntityEnclosingRequest("GET", uri2.toString());
|
||||
new BasicHttpEntityEnclosingRequest("GET", uri2.toString(), null);
|
||||
|
||||
RequestBuilder.get(uri2);
|
||||
RequestBuilder.post(uri2);
|
||||
RequestBuilder.put(uri2);
|
||||
RequestBuilder.delete(uri2);
|
||||
RequestBuilder.options(uri2);
|
||||
RequestBuilder.head(uri2);
|
||||
RequestBuilder.trace(uri2);
|
||||
RequestBuilder.patch(uri2);
|
||||
RequestBuilder.get("").setUri(uri2);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -41,14 +42,22 @@ public class SpringSSRF extends HttpServlet {
|
||||
restTemplate.execute(fooResourceUrl, HttpMethod.POST, null, null, "test");
|
||||
}
|
||||
{
|
||||
ResponseEntity<String> response =
|
||||
restTemplate.getForEntity(fooResourceUrl, String.class, "test");
|
||||
String response =
|
||||
restTemplate.getForObject(fooResourceUrl, String.class, "test");
|
||||
}
|
||||
{
|
||||
String body = new String("body");
|
||||
URI uri = new URI(fooResourceUrl);
|
||||
RequestEntity<String> requestEntity =
|
||||
RequestEntity.post(new URI(fooResourceUrl)).body(body);
|
||||
RequestEntity.post(uri).body(body);
|
||||
ResponseEntity<String> response = restTemplate.exchange(requestEntity, String.class);
|
||||
RequestEntity.get(uri);
|
||||
RequestEntity.put(uri);
|
||||
RequestEntity.delete(uri);
|
||||
RequestEntity.options(uri);
|
||||
RequestEntity.patch(uri);
|
||||
RequestEntity.head(uri);
|
||||
RequestEntity.method(null, uri);
|
||||
}
|
||||
{
|
||||
String response = restTemplate.patchForObject(fooResourceUrl, new String("object"),
|
||||
@@ -68,6 +77,23 @@ public class SpringSSRF extends HttpServlet {
|
||||
{
|
||||
restTemplate.put(fooResourceUrl, new String("object"));
|
||||
}
|
||||
{
|
||||
URI uri = new URI(fooResourceUrl);
|
||||
MultiValueMap<String, String> headers = null;
|
||||
java.lang.reflect.Type type = null;
|
||||
new RequestEntity<String>(null, uri);
|
||||
new RequestEntity<String>(headers, null, uri);
|
||||
new RequestEntity<String>("body", null, uri);
|
||||
new RequestEntity<String>("body", headers, null, uri);
|
||||
new RequestEntity<String>("body", null, uri, type);
|
||||
new RequestEntity<String>("body", headers, null, uri, type);
|
||||
}
|
||||
{
|
||||
URI uri = new URI(fooResourceUrl);
|
||||
restTemplate.delete(uri);
|
||||
restTemplate.headForHeaders(uri);
|
||||
restTemplate.optionsForAllow(uri);
|
||||
}
|
||||
} catch (org.springframework.web.client.RestClientException | java.net.URISyntaxException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.http.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* This annotation defines behavioral contract enforced at runtime by instances of annotated classes.
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface Contract {
|
||||
|
||||
ThreadingBehavior threading() default ThreadingBehavior.UNSAFE;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.apache.http.annotation.ThreadingBehavior;
|
||||
import org.apache.http.annotation.Contract;
|
||||
|
||||
/**
|
||||
* Holds all of the variables needed to describe an HTTP connection to a host.
|
||||
* This includes remote host name, port and scheme.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Contract(threading = ThreadingBehavior.IMMUTABLE)
|
||||
public final class HttpHost implements Cloneable, Serializable {
|
||||
|
||||
/** The default scheme is "http". */
|
||||
public static final String DEFAULT_SCHEME_NAME = "http";
|
||||
|
||||
/**
|
||||
* Creates {@code HttpHost} instance with the given scheme, hostname and port.
|
||||
*
|
||||
* @param hostname the hostname (IP or DNS name)
|
||||
* @param port the port number.
|
||||
* {@code -1} indicates the scheme default port.
|
||||
* @param scheme the name of the scheme.
|
||||
* {@code null} indicates the
|
||||
* {@link #DEFAULT_SCHEME_NAME default scheme}
|
||||
*/
|
||||
public HttpHost(final String hostname, final int port, final String scheme) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@code HttpHost} instance with the default scheme and the given hostname and port.
|
||||
*
|
||||
* @param hostname the hostname (IP or DNS name)
|
||||
* @param port the port number.
|
||||
* {@code -1} indicates the scheme default port.
|
||||
*/
|
||||
public HttpHost(final String hostname, final int port) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@code HttpHost} instance from string. Text may not contain any blanks.
|
||||
*
|
||||
* @since 4.4
|
||||
*/
|
||||
public static HttpHost create(final String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@code HttpHost} instance with the default scheme and port and the given hostname.
|
||||
*
|
||||
* @param hostname the hostname (IP or DNS name)
|
||||
*/
|
||||
public HttpHost(final String hostname) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@code HttpHost} instance with the given scheme, inet address and port.
|
||||
*
|
||||
* @param address the inet address.
|
||||
* @param port the port number.
|
||||
* {@code -1} indicates the scheme default port.
|
||||
* @param scheme the name of the scheme.
|
||||
* {@code null} indicates the
|
||||
* {@link #DEFAULT_SCHEME_NAME default scheme}
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address, final int port, final String scheme) {
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, specifying all values.
|
||||
* Constructor for HttpHost.
|
||||
*
|
||||
* @param address the inet address.
|
||||
* @param hostname the hostname (IP or DNS name)
|
||||
* @param port the port number.
|
||||
* {@code -1} indicates the scheme default port.
|
||||
* @param scheme the name of the scheme.
|
||||
* {@code null} indicates the
|
||||
* {@link #DEFAULT_SCHEME_NAME default scheme}
|
||||
*
|
||||
* @since 4.4
|
||||
*/
|
||||
public HttpHost(final InetAddress address, final String hostname, final int port, final String scheme) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@code HttpHost} instance with the default scheme and the given inet address
|
||||
* and port.
|
||||
*
|
||||
* @param address the inet address.
|
||||
* @param port the port number.
|
||||
* {@code -1} indicates the scheme default port.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address, final int port) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@code HttpHost} instance with the default scheme and port and the given inet
|
||||
* address.
|
||||
*
|
||||
* @param address the inet address.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor for {@link HttpHost HttpHost}.
|
||||
*
|
||||
* @param httphost the HTTP host to copy details from
|
||||
*/
|
||||
public HttpHost (final HttpHost httphost) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the host name.
|
||||
*
|
||||
* @return the host name (IP or DNS name)
|
||||
*/
|
||||
public String getHostName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port.
|
||||
*
|
||||
* @return the host port, or {@code -1} if not set
|
||||
*/
|
||||
public int getPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scheme name.
|
||||
*
|
||||
* @return the scheme name
|
||||
*/
|
||||
public String getSchemeName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the inet address if explicitly set by a constructor,
|
||||
* {@code null} otherwise.
|
||||
* @return the inet address
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public InetAddress getAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the host URI, as a string.
|
||||
*
|
||||
* @return the host URI
|
||||
*/
|
||||
public String toURI() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the host string, without scheme prefix.
|
||||
*
|
||||
* @return the host string, for example {@code localhost:8080}
|
||||
*/
|
||||
public String toHostString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.http.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* This annotation defines behavioral contract enforced at runtime by instances of annotated classes.
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface Contract {
|
||||
|
||||
ThreadingBehavior threading() default ThreadingBehavior.UNSAFE;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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.annotation;
|
||||
|
||||
/**
|
||||
Defines types of threading behavior enforced at runtime.
|
||||
*/
|
||||
public enum ThreadingBehavior {
|
||||
|
||||
/**
|
||||
* Instances of classes with the given contract are expected to be fully immutable
|
||||
* and thread-safe.
|
||||
*/
|
||||
IMMUTABLE,
|
||||
|
||||
/**
|
||||
* Instances of classes with the given contract are expected to be immutable if their
|
||||
* dependencies injected at construction time are immutable and are expected to be thread-safe
|
||||
* if their dependencies are thread-safe.
|
||||
*/
|
||||
IMMUTABLE_CONDITIONAL,
|
||||
|
||||
/**
|
||||
* Instances of classes with the given contract are expected to be fully thread-safe.
|
||||
*/
|
||||
SAFE,
|
||||
|
||||
/**
|
||||
* Instances of classes with the given contract are expected to be thread-safe if their
|
||||
* dependencies injected at construction time are thread-safe.
|
||||
*/
|
||||
SAFE_CONDITIONAL,
|
||||
|
||||
/**
|
||||
* Instances of classes with the given contract are expected to be non thread-safe.
|
||||
*/
|
||||
UNSAFE
|
||||
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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.config;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.annotation.Contract;
|
||||
import org.apache.http.annotation.ThreadingBehavior;
|
||||
|
||||
/**
|
||||
* Immutable class encapsulating request configuration items.
|
||||
* The default setting for stale connection checking changed
|
||||
* to false, and the feature was deprecated starting with version 4.4.
|
||||
*/
|
||||
@Contract(threading = ThreadingBehavior.IMMUTABLE)
|
||||
public class RequestConfig implements Cloneable {
|
||||
|
||||
public static final RequestConfig DEFAULT = null;
|
||||
|
||||
/**
|
||||
* Intended for CDI compatibility
|
||||
*/
|
||||
protected RequestConfig() {
|
||||
}
|
||||
|
||||
RequestConfig(
|
||||
final boolean expectContinueEnabled,
|
||||
final HttpHost proxy,
|
||||
final InetAddress localAddress,
|
||||
final boolean staleConnectionCheckEnabled,
|
||||
final String cookieSpec,
|
||||
final boolean redirectsEnabled,
|
||||
final boolean relativeRedirectsAllowed,
|
||||
final boolean circularRedirectsAllowed,
|
||||
final int maxRedirects,
|
||||
final boolean authenticationEnabled,
|
||||
final Collection<String> targetPreferredAuthSchemes,
|
||||
final Collection<String> proxyPreferredAuthSchemes,
|
||||
final int connectionRequestTimeout,
|
||||
final int connectTimeout,
|
||||
final int socketTimeout,
|
||||
final boolean contentCompressionEnabled,
|
||||
final boolean normalizeUri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the 'Expect: 100-Continue' handshake is enabled
|
||||
* for entity enclosing methods. The purpose of the 'Expect: 100-Continue'
|
||||
* handshake is to allow a client that is sending a request message with
|
||||
* a request body to determine if the origin server is willing to
|
||||
* accept the request (based on the request headers) before the client
|
||||
* sends the request body.
|
||||
* <p>
|
||||
* The use of the 'Expect: 100-continue' handshake can result in
|
||||
* a noticeable performance improvement for entity enclosing requests
|
||||
* (such as POST and PUT) that require the target server's
|
||||
* authentication.
|
||||
* </p>
|
||||
* <p>
|
||||
* 'Expect: 100-continue' handshake should be used with caution, as it
|
||||
* may cause problems with HTTP servers and proxies that do not support
|
||||
* HTTP/1.1 protocol.
|
||||
* </p>
|
||||
* <p>
|
||||
* Default: {@code false}
|
||||
* </p>
|
||||
*/
|
||||
public boolean isExpectContinueEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTTP proxy to be used for request execution.
|
||||
* <p>
|
||||
* Default: {@code null}
|
||||
* </p>
|
||||
*/
|
||||
public HttpHost getProxy() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns local address to be used for request execution.
|
||||
* <p>
|
||||
* On machines with multiple network interfaces, this parameter
|
||||
* can be used to select the network interface from which the
|
||||
* connection originates.
|
||||
* </p>
|
||||
* <p>
|
||||
* Default: {@code null}
|
||||
* </p>
|
||||
*/
|
||||
public InetAddress getLocalAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether stale connection check is to be used. The stale
|
||||
* connection check can cause up to 30 millisecond overhead per request and
|
||||
* should be used only when appropriate. For performance critical
|
||||
* operations this check should be disabled.
|
||||
* <p>
|
||||
* Default: {@code false} since 4.4
|
||||
* </p>
|
||||
*
|
||||
* @deprecated (4.4) Use {@link
|
||||
* org.apache.http.impl.conn.PoolingHttpClientConnectionManager#getValidateAfterInactivity()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isStaleConnectionCheckEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the name of the cookie specification to be used for HTTP state
|
||||
* management.
|
||||
* <p>
|
||||
* Default: {@code null}
|
||||
* </p>
|
||||
*/
|
||||
public String getCookieSpec() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether redirects should be handled automatically.
|
||||
* <p>
|
||||
* Default: {@code true}
|
||||
* </p>
|
||||
*/
|
||||
public boolean isRedirectsEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether relative redirects should be rejected. HTTP specification
|
||||
* requires the location value be an absolute URI.
|
||||
* <p>
|
||||
* Default: {@code true}
|
||||
* </p>
|
||||
*/
|
||||
public boolean isRelativeRedirectsAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether circular redirects (redirects to the same location) should
|
||||
* be allowed. The HTTP spec is not sufficiently clear whether circular redirects
|
||||
* are permitted, therefore optionally they can be enabled
|
||||
* <p>
|
||||
* Default: {@code false}
|
||||
* </p>
|
||||
*/
|
||||
public boolean isCircularRedirectsAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of redirects to be followed. The limit on number
|
||||
* of redirects is intended to prevent infinite loops.
|
||||
* <p>
|
||||
* Default: {@code 50}
|
||||
* </p>
|
||||
*/
|
||||
public int getMaxRedirects() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether authentication should be handled automatically.
|
||||
* <p>
|
||||
* Default: {@code true}
|
||||
* </p>
|
||||
*/
|
||||
public boolean isAuthenticationEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the order of preference for supported authentication schemes
|
||||
* when authenticating with the target host.
|
||||
* <p>
|
||||
* Default: {@code null}
|
||||
* </p>
|
||||
*/
|
||||
public Collection<String> getTargetPreferredAuthSchemes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the order of preference for supported authentication schemes
|
||||
* when authenticating with the proxy host.
|
||||
* <p>
|
||||
* Default: {@code null}
|
||||
* </p>
|
||||
*/
|
||||
public Collection<String> getProxyPreferredAuthSchemes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timeout in milliseconds used when requesting a connection
|
||||
* from the connection manager.
|
||||
* <p>
|
||||
* A timeout value of zero is interpreted as an infinite timeout.
|
||||
* A negative value is interpreted as undefined (system default if applicable).
|
||||
* </p>
|
||||
* <p>
|
||||
* Default: {@code -1}
|
||||
* </p>
|
||||
*/
|
||||
public int getConnectionRequestTimeout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the timeout in milliseconds until a connection is established.
|
||||
* <p>
|
||||
* A timeout value of zero is interpreted as an infinite timeout.
|
||||
* A negative value is interpreted as undefined (system default if applicable).
|
||||
* </p>
|
||||
* <p>
|
||||
* Default: {@code -1}
|
||||
* </p>
|
||||
*/
|
||||
public int getConnectTimeout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the socket timeout ({@code SO_TIMEOUT}) in milliseconds,
|
||||
* which is the timeout for waiting for data or, put differently,
|
||||
* a maximum period inactivity between two consecutive data packets).
|
||||
* <p>
|
||||
* A timeout value of zero is interpreted as an infinite timeout.
|
||||
* A negative value is interpreted as undefined (system default if applicable).
|
||||
* </p>
|
||||
* <p>
|
||||
* Default: {@code -1}
|
||||
* </p>
|
||||
*/
|
||||
public int getSocketTimeout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether compressed entities should be decompressed automatically.
|
||||
* <p>
|
||||
* Default: {@code true}
|
||||
* </p>
|
||||
*
|
||||
* @since 4.4
|
||||
* @deprecated (4.5) Use {@link #isContentCompressionEnabled()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isDecompressionEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the target server is requested to compress content.
|
||||
* <p>
|
||||
* Default: {@code true}
|
||||
* </p>
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
public boolean isContentCompressionEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether client should normalize URIs in requests or not.
|
||||
* <p>
|
||||
* Default: {@code true}
|
||||
* </p>
|
||||
*
|
||||
* @since 4.5.8
|
||||
*/
|
||||
public boolean isNormalizeUri() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestConfig clone() throws CloneNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestConfig.Builder custom() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static RequestConfig.Builder copy(final RequestConfig config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
Builder() {
|
||||
}
|
||||
|
||||
public Builder setExpectContinueEnabled(final boolean expectContinueEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setProxy(final HttpHost proxy) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setLocalAddress(final InetAddress localAddress) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated (4.4) Use {@link
|
||||
* org.apache.http.impl.conn.PoolingHttpClientConnectionManager#setValidateAfterInactivity(int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder setStaleConnectionCheckEnabled(final boolean staleConnectionCheckEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setCookieSpec(final String cookieSpec) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setRedirectsEnabled(final boolean redirectsEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setRelativeRedirectsAllowed(final boolean relativeRedirectsAllowed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setCircularRedirectsAllowed(final boolean circularRedirectsAllowed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setMaxRedirects(final int maxRedirects) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setAuthenticationEnabled(final boolean authenticationEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setTargetPreferredAuthSchemes(final Collection<String> targetPreferredAuthSchemes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setProxyPreferredAuthSchemes(final Collection<String> proxyPreferredAuthSchemes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setConnectionRequestTimeout(final int connectionRequestTimeout) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setConnectTimeout(final int connectTimeout) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setSocketTimeout(final int socketTimeout) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated (4.5) Set {@link #setContentCompressionEnabled(boolean)} to {@code false} and
|
||||
* add the {@code Accept-Encoding} request header.
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder setDecompressionEnabled(final boolean decompressionEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setContentCompressionEnabled(final boolean contentCompressionEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Builder setNormalizeUri(final boolean normalizeUri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestConfig build() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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 DELETE method
|
||||
* <p>
|
||||
* The HTTP DELETE method is defined in section 9.7 of
|
||||
* <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
|
||||
* <blockquote>
|
||||
* The DELETE method requests that the origin server delete the resource
|
||||
* identified by the Request-URI. [...] The client cannot
|
||||
* be guaranteed that the operation has been carried out, even if the
|
||||
* status code returned from the origin server indicates that the action
|
||||
* has been completed successfully.
|
||||
* </blockquote>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HttpDelete extends HttpRequestBase {
|
||||
|
||||
public final static String METHOD_NAME = "DELETE";
|
||||
|
||||
|
||||
public HttpDelete() {
|
||||
}
|
||||
|
||||
public HttpDelete(final URI uri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the uri is invalid.
|
||||
*/
|
||||
public HttpDelete(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.http.client.methods;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* HTTP HEAD method.
|
||||
* <p>
|
||||
* The HTTP HEAD method is defined in section 9.4 of
|
||||
* <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
|
||||
* </p>
|
||||
* <blockquote>
|
||||
* The HEAD method is identical to GET except that the server MUST NOT
|
||||
* return a message-body in the response. The metainformation contained
|
||||
* in the HTTP headers in response to a HEAD request SHOULD be identical
|
||||
* to the information sent in response to a GET request. This method can
|
||||
* be used for obtaining metainformation about the entity implied by the
|
||||
* request without transferring the entity-body itself. This method is
|
||||
* often used for testing hypertext links for validity, accessibility,
|
||||
* and recent modification.
|
||||
* </blockquote>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HttpHead extends HttpRequestBase {
|
||||
|
||||
public final static String METHOD_NAME = "HEAD";
|
||||
|
||||
public HttpHead() {
|
||||
}
|
||||
|
||||
public HttpHead(final URI uri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the uri is invalid.
|
||||
*/
|
||||
public HttpHead(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HeaderElement;
|
||||
import org.apache.http.HeaderIterator;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.Args;
|
||||
|
||||
/**
|
||||
* HTTP OPTIONS method.
|
||||
* <p>
|
||||
* The HTTP OPTIONS method is defined in section 9.2 of
|
||||
* <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
|
||||
* </p>
|
||||
* <blockquote>
|
||||
* The OPTIONS method represents a request for information about the
|
||||
* communication options available on the request/response chain
|
||||
* identified by the Request-URI. This method allows the client to
|
||||
* determine the options and/or requirements associated with a resource,
|
||||
* or the capabilities of a server, without implying a resource action
|
||||
* or initiating a resource retrieval.
|
||||
* </blockquote>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HttpOptions extends HttpRequestBase {
|
||||
|
||||
public final static String METHOD_NAME = "OPTIONS";
|
||||
|
||||
public HttpOptions() {
|
||||
}
|
||||
|
||||
public HttpOptions(final URI uri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the uri is invalid.
|
||||
*/
|
||||
public HttpOptions(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getAllowedMethods(final HttpResponse response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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 PATCH method.
|
||||
* <p>
|
||||
* The HTTP PATCH method is defined in <a
|
||||
* href="http://tools.ietf.org/html/rfc5789">RF5789</a>:
|
||||
* </p>
|
||||
* <blockquote> The PATCH
|
||||
* method requests that a set of changes described in the request entity be
|
||||
* applied to the resource identified by the Request- URI. Differs from the PUT
|
||||
* method in the way the server processes the enclosed entity to modify the
|
||||
* resource identified by the Request-URI. In a PUT request, the enclosed entity
|
||||
* origin server, and the client is requesting that the stored version be
|
||||
* replaced. With PATCH, however, the enclosed entity contains a set of
|
||||
* instructions describing how a resource currently residing on the origin
|
||||
* server should be modified to produce a new version.
|
||||
* </blockquote>
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public class HttpPatch extends HttpEntityEnclosingRequestBase {
|
||||
|
||||
public final static String METHOD_NAME = "PATCH";
|
||||
|
||||
public HttpPatch() {
|
||||
}
|
||||
|
||||
public HttpPatch(final URI uri) {
|
||||
}
|
||||
|
||||
public HttpPatch(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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 TRACE method.
|
||||
* <p>
|
||||
* The HTTP TRACE method is defined in section 9.6 of
|
||||
* <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
|
||||
* </p>
|
||||
* <blockquote>
|
||||
* The TRACE method is used to invoke a remote, application-layer loop-
|
||||
* back of the request message. The final recipient of the request
|
||||
* SHOULD reflect the message received back to the client as the
|
||||
* entity-body of a 200 (OK) response. The final recipient is either the
|
||||
* origin server or the first proxy or gateway to receive a Max-Forwards
|
||||
* value of zero (0) in the request (see section 14.31). A TRACE request
|
||||
* MUST NOT include an entity.
|
||||
* </blockquote>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HttpTrace extends HttpRequestBase {
|
||||
|
||||
public final static String METHOD_NAME = "TRACE";
|
||||
|
||||
public HttpTrace() {
|
||||
}
|
||||
|
||||
public HttpTrace(final URI uri) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException if the uri is invalid.
|
||||
*/
|
||||
public HttpTrace(final String uri) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return METHOD_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
|
||||
import org.apache.http.HttpRequest;
|
||||
|
||||
/**
|
||||
* Extended version of the {@link HttpRequest} interface that provides
|
||||
* convenience methods to access request properties such as request URI
|
||||
* and method type.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpUriRequest extends HttpRequest {
|
||||
|
||||
/**
|
||||
* Returns the HTTP method this request uses, such as {@code GET},
|
||||
* {@code PUT}, {@code POST}, or other.
|
||||
*/
|
||||
String getMethod();
|
||||
|
||||
/**
|
||||
* Returns the URI this request uses, such as
|
||||
* {@code http://example.org/path/to/file}.
|
||||
* <p>
|
||||
* Note that the URI may be absolute URI (as above) or may be a relative URI.
|
||||
* </p>
|
||||
* <p>
|
||||
* Implementations are encouraged to return
|
||||
* the URI that was initially requested.
|
||||
* </p>
|
||||
* <p>
|
||||
* To find the final URI after any redirects have been processed,
|
||||
* please see the section entitled
|
||||
* <a href="http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#d4e205">HTTP execution context</a>
|
||||
* in the
|
||||
* <a href="http://hc.apache.org/httpcomponents-client-ga/tutorial/html">HttpClient Tutorial</a>
|
||||
* </p>
|
||||
*/
|
||||
URI getURI();
|
||||
|
||||
/**
|
||||
* Aborts execution of the request.
|
||||
*
|
||||
* @throws UnsupportedOperationException if the abort operation
|
||||
* is not supported / cannot be implemented.
|
||||
*/
|
||||
void abort() throws UnsupportedOperationException;
|
||||
|
||||
/**
|
||||
* Tests if the request execution has been aborted.
|
||||
*
|
||||
* @return {@code true} if the request execution has been aborted,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean isAborted();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpEntityEnclosingRequest;
|
||||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
|
||||
/**
|
||||
* Builder for {@link HttpUriRequest} instances.
|
||||
* <p>
|
||||
* Please note that this class treats parameters differently depending on composition
|
||||
* of the request: if the request has a content entity explicitly set with
|
||||
* {@link #setEntity(org.apache.http.HttpEntity)} or it is not an entity enclosing method
|
||||
* (such as POST or PUT), parameters will be added to the query component of the request URI.
|
||||
* Otherwise, parameters will be added as a URL encoded {@link UrlEncodedFormEntity entity}.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public class RequestBuilder {
|
||||
|
||||
RequestBuilder(final String method) {
|
||||
}
|
||||
|
||||
RequestBuilder(final String method, final URI uri) {
|
||||
}
|
||||
|
||||
RequestBuilder(final String method, final String uri) {
|
||||
}
|
||||
|
||||
RequestBuilder() {
|
||||
}
|
||||
|
||||
public static RequestBuilder create(final String method) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder get() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder get(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder get(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder head() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder head(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder head(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder patch() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder patch(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder patch(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder post() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder post(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder post(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder put() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder put(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder put(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder delete() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder delete(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder delete(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder trace() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder trace(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder trace(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder options() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder options(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public static RequestBuilder options(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static RequestBuilder copy(final HttpRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestBuilder doCopy(final HttpRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public RequestBuilder setCharset(final Charset charset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public Charset getCharset() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ProtocolVersion getVersion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder setVersion(final ProtocolVersion version) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URI getUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder setUri(final URI uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder setUri(final String uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Header getFirstHeader(final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Header getLastHeader(final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Header[] getHeaders(final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder addHeader(final Header header) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder addHeader(final String name, final String value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder removeHeader(final Header header) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder removeHeaders(final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder setHeader(final Header header) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder setHeader(final String name, final String value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpEntity getEntity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder setEntity(final HttpEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<NameValuePair> getParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder addParameter(final NameValuePair nvp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder addParameter(final String name, final String value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder addParameters(final NameValuePair... nvps) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestConfig getConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestBuilder setConfig(final RequestConfig config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpUriRequest build() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class InternalRequest extends HttpRequestBase {
|
||||
|
||||
InternalRequest(final String method) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class InternalEntityEclosingRequest extends HttpEntityEnclosingRequestBase {
|
||||
|
||||
InternalEntityEclosingRequest(final String method) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user