You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/11/05 21:50:14 UTC
httpcomponents-core git commit: Added #reset method to
AsyncRequestProducer [Forced Update!]
Repository: httpcomponents-core
Updated Branches:
refs/heads/master 0194db53d -> 57802047a (forced update)
Added #reset method to AsyncRequestProducer
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/57802047
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/57802047
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/57802047
Branch: refs/heads/master
Commit: 57802047a1fa99eebca79424cb6008fe9bb093f4
Parents: b70a294
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Nov 5 19:48:39 2017 +0100
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Nov 5 22:46:08 2017 +0100
----------------------------------------------------------------------
.../http/NonRepeatableEntityException.java | 46 ++++++++++++++++++++
.../hc/core5/http/nio/AsyncRequestProducer.java | 5 +++
.../hc/core5/http/nio/BasicRequestProducer.java | 17 ++++++++
3 files changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/57802047/httpcore5/src/main/java/org/apache/hc/core5/http/NonRepeatableEntityException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/NonRepeatableEntityException.java b/httpcore5/src/main/java/org/apache/hc/core5/http/NonRepeatableEntityException.java
new file mode 100644
index 0000000..a5e20e0
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/NonRepeatableEntityException.java
@@ -0,0 +1,46 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http;
+
+/**
+ * Signals a failure to execute an operation due to an HTTP entity
+ * being unable to repeat its content.
+ *
+ * @since 5.0
+ */
+public class NonRepeatableEntityException extends HttpException {
+
+ public NonRepeatableEntityException() {
+ super();
+ }
+
+ public NonRepeatableEntityException(final String message) {
+ super(message);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/57802047/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncRequestProducer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncRequestProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncRequestProducer.java
index 71d0e8f..de56b0c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncRequestProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncRequestProducer.java
@@ -29,6 +29,7 @@ package org.apache.hc.core5.http.nio;
import java.io.IOException;
import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.NonRepeatableEntityException;
/**
* Abstract asynchronous request producer.
@@ -39,6 +40,10 @@ public interface AsyncRequestProducer extends AsyncDataProducer {
void sendRequest(RequestChannel requestChannel) throws HttpException, IOException;
+ boolean isRepeatable();
+
+ void reset() throws NonRepeatableEntityException;
+
void failed(Exception cause);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/57802047/httpcore5/src/main/java/org/apache/hc/core5/http/nio/BasicRequestProducer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/BasicRequestProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/BasicRequestProducer.java
index 4e22f7a..3b9e5db 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/BasicRequestProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/BasicRequestProducer.java
@@ -32,6 +32,7 @@ import java.net.URI;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.NonRepeatableEntityException;
import org.apache.hc.core5.http.message.BasicHttpRequest;
public class BasicRequestProducer implements AsyncRequestProducer {
@@ -78,6 +79,22 @@ public class BasicRequestProducer implements AsyncRequestProducer {
}
@Override
+ public boolean isRepeatable() {
+ return dataProducer == null || dataProducer.isRepeatable();
+ }
+
+ @Override
+ public void reset() throws NonRepeatableEntityException {
+ if (dataProducer != null) {
+ if (dataProducer.isRepeatable()) {
+ dataProducer.releaseResources();
+ } else {
+ throw new NonRepeatableEntityException("Request entity content cannot be repeated");
+ }
+ }
+ }
+
+ @Override
public void failed(final Exception cause) {
try {
if (dataProducer != null) {