├── modules
└── httpcore-nio
│ └── src
│ ├── test
│ ├── resources
│ │ └── test.keystore
│ └── java
│ │ └── org
│ │ └── apache
│ │ └── http
│ │ ├── OoopsieRuntimeException.java
│ │ ├── nio
│ │ ├── testserver
│ │ │ ├── LoggingClientConnectionFactory.java
│ │ │ ├── LoggingServerConnectionFactory.java
│ │ │ ├── SimpleIOReactorExceptionHandler.java
│ │ │ ├── LoggingSSLClientConnectionFactory.java
│ │ │ └── LoggingSSLServerConnectionFactory.java
│ │ ├── integration
│ │ │ ├── RndTestPatternGenerator.java
│ │ │ └── TestHttpsAsyncHandlers.java
│ │ └── util
│ │ │ ├── ContentDecoderMock.java
│ │ │ └── ContentEncoderMock.java
│ │ ├── impl
│ │ └── nio
│ │ │ ├── reactor
│ │ │ ├── ExceptionEventTest.java
│ │ │ └── TestDefaultIOReactorsSSL.java
│ │ │ ├── codecs
│ │ │ └── CodecTestUtils.java
│ │ │ └── TestContentChannel.java
│ │ └── ByteChannelMock.java
│ └── main
│ ├── resources
│ └── org
│ │ └── apache
│ │ └── http
│ │ └── nio
│ │ └── version.properties
│ ├── java
│ └── org
│ │ └── apache
│ │ └── http
│ │ ├── nio
│ │ ├── params
│ │ │ ├── package-info.java
│ │ │ └── NIOReactorPNames.java
│ │ ├── util
│ │ │ ├── package-info.java
│ │ │ ├── BufferInfo.java
│ │ │ ├── ByteBufferAllocator.java
│ │ │ ├── HeapByteBufferAllocator.java
│ │ │ └── DirectByteBufferAllocator.java
│ │ ├── reactor
│ │ │ ├── ssl
│ │ │ │ ├── package-info.java
│ │ │ │ ├── SSLMode.java
│ │ │ │ └── SSLSetupHandler.java
│ │ │ ├── package-info.java
│ │ │ ├── SocketAccessor.java
│ │ │ ├── EventMask.java
│ │ │ ├── IOReactorStatus.java
│ │ │ ├── IOReactorException.java
│ │ │ ├── SessionBufferStatus.java
│ │ │ ├── SessionRequestCallback.java
│ │ │ ├── IOReactorExceptionHandler.java
│ │ │ └── ListenerEndpoint.java
│ │ ├── package-info.java
│ │ ├── pool
│ │ │ ├── package-info.java
│ │ │ ├── SocketAddressResolver.java
│ │ │ └── NIOConnFactory.java
│ │ ├── protocol
│ │ │ ├── MessageState.java
│ │ │ ├── package-info.java
│ │ │ ├── HttpAsyncRequestHandlerMapper.java
│ │ │ ├── HttpAsyncRequestHandlerResolver.java
│ │ │ ├── HttpAsyncExpectationVerifier.java
│ │ │ ├── NullRequestHandler.java
│ │ │ ├── NullRequestConsumer.java
│ │ │ └── BasicAsyncRequestHandler.java
│ │ ├── entity
│ │ │ ├── package-info.java
│ │ │ ├── ConsumingNHttpEntity.java
│ │ │ ├── ContentOutputStream.java
│ │ │ ├── ProducingNHttpEntity.java
│ │ │ └── ContentBufferEntity.java
│ │ ├── NHttpConnectionFactory.java
│ │ ├── NHttpMessageWriterFactory.java
│ │ ├── NHttpMessageParserFactory.java
│ │ ├── NHttpClientIOTarget.java
│ │ ├── NHttpMessageWriter.java
│ │ ├── NHttpServerIOTarget.java
│ │ ├── ContentDecoderChannel.java
│ │ ├── ContentEncoderChannel.java
│ │ ├── FileContentEncoder.java
│ │ ├── ContentDecoder.java
│ │ ├── ContentEncoder.java
│ │ ├── IOControl.java
│ │ ├── FileContentDecoder.java
│ │ ├── NHttpMessageParser.java
│ │ ├── NHttpClientConnection.java
│ │ └── NHttpServerConnection.java
│ │ └── impl
│ │ └── nio
│ │ ├── package-info.java
│ │ ├── reactor
│ │ ├── package-info.java
│ │ ├── SessionClosedCallback.java
│ │ ├── InterestOpsCallback.java
│ │ ├── ListenerEndpointClosedCallback.java
│ │ ├── SessionRequestHandle.java
│ │ ├── ExceptionEvent.java
│ │ └── InterestOpEntry.java
│ │ ├── pool
│ │ ├── package-info.java
│ │ └── BasicNIOPoolEntry.java
│ │ ├── codecs
│ │ ├── package-info.java
│ │ ├── DefaultHttpRequestWriterFactory.java
│ │ └── DefaultHttpResponseWriterFactory.java
│ │ ├── SessionHttpContext.java
│ │ └── SSLContextUtils.java
│ └── java-deprecated
│ └── org
│ └── apache
│ └── http
│ ├── impl
│ └── nio
│ │ ├── reactor
│ │ ├── SSLMode.java
│ │ ├── SSLSetupHandlerAdaptor.java
│ │ └── SSLIOSessionHandlerAdaptor.java
│ │ └── codecs
│ │ ├── HttpRequestWriter.java
│ │ └── HttpResponseWriter.java
│ └── nio
│ ├── params
│ └── NIOReactorParamBean.java
│ ├── protocol
│ ├── NHttpRequestHandlerResolver.java
│ ├── SimpleNHttpRequestHandler.java
│ ├── NHttpResponseTrigger.java
│ ├── EventListener.java
│ └── HttpAsyncRequestExecutionHandler.java
│ └── entity
│ ├── ContentListener.java
│ └── SkipContentListener.java
├── .github
├── CODEOWNERS
└── workflows
│ ├── push_ubuntu_build.yml
│ └── pull_request_ubuntu_build.yml
├── README.md
├── .gitignore
├── issue_template.md
└── pull_request_template.md
/modules/httpcore-nio/src/test/resources/test.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wso2/wso2-httpcore-nio/HEAD/modules/httpcore-nio/src/test/resources/test.keystore
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Lines starting with '#' are comments.
2 | # Each line is a file pattern followed by one or more owners.
3 |
4 | # See: https://help.github.com/articles/about-codeowners/
5 |
6 | # These owners will be the default owners for everything in the repo.
7 | * @arunans23
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # wso2-httpcore-nio
2 |
3 | ##Jenkins Build Status
4 |
5 | | Branch | Build Status |
6 | | :------------ |:-------------
7 | | wso2-httpcore-nio master | [](https://wso2.org/jenkins/job/wso2-httpcore-nio)
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Mobile Tools for Java (J2ME)
4 | .mtj.tmp/
5 |
6 | # Package Files #
7 | *.jar
8 | *.war
9 | *.ear
10 |
11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12 | hs_err_pid*
13 |
14 | # ignore Intellij-IDEA files
15 | *.iml
16 | *.ipr
17 | *.iws
18 | *.classpath
19 | *.settings
20 | *.project
21 | *.idea
22 |
23 |
24 | # ignore logs
25 | *.log
26 |
27 | # ignore target directories
28 | target/
29 |
--------------------------------------------------------------------------------
/.github/workflows/push_ubuntu_build.yml:
--------------------------------------------------------------------------------
1 | name: CI - Push request - Ubuntu
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 |
7 | jobs:
8 | build:
9 |
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - uses: actions/checkout@v4
14 | - name: Set up JDK 11
15 | uses: actions/setup-java@v4
16 | with:
17 | java-version: '11'
18 | distribution: 'temurin'
19 | cache: maven
20 | - name: Build with Maven
21 | run: mvn clean install
22 | - name: Upload test coverage to Codecov
23 | uses: codecov/codecov-action@v4.0.1
24 | with:
25 | flags: unit_tests
26 | token: ${{ secrets.CODECOV_TOKEN }}
27 |
--------------------------------------------------------------------------------
/.github/workflows/pull_request_ubuntu_build.yml:
--------------------------------------------------------------------------------
1 | name: CI - Pull request - Ubuntu
2 |
3 | on:
4 | pull_request:
5 | branches: [ "master" ]
6 |
7 | jobs:
8 | build:
9 |
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - uses: actions/checkout@v4
14 | - name: Set up JDK 11
15 | uses: actions/setup-java@v4
16 | with:
17 | java-version: '11'
18 | distribution: 'temurin'
19 | cache: maven
20 | - name: Build with Maven
21 | run: mvn clean install
22 | - name: Upload test coverage to Codecov
23 | uses: codecov/codecov-action@v4.0.1
24 | with:
25 | flags: unit_tests
26 | token: ${{ secrets.CODECOV_TOKEN }}
27 |
--------------------------------------------------------------------------------
/issue_template.md:
--------------------------------------------------------------------------------
1 | **Description:**
2 |
3 |
4 | **Suggested Labels:**
5 |
6 |
7 | **Suggested Assignees:**
8 |
9 |
10 | **Affected Product Version:**
11 |
12 | **OS, DB, other environment details and versions:**
13 |
14 | **Steps to reproduce:**
15 |
16 |
17 | **Related Issues:**
18 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/resources/org/apache/http/nio/version.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 | #
19 | info.module = Httpcore-nio
20 | info.release = ${pom.version}
21 | info.timestamp = ${mvn.timestamp}
22 | # timestamp requires Maven 2.1
23 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/params/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Deprecated.
30 | * @deprecated (4.3).
31 | */
32 | package org.apache.http.nio.params;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/util/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Core utility classes for asynchronous, event driven communication.
30 | */
31 | package org.apache.http.nio.util;
32 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * TLS/SSL support for asynchronous, event driven communication.
30 | */
31 | package org.apache.http.nio.reactor.ssl;
32 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Core HTTP component APIs and primitives for asynchronous, event
30 | * driven communication.
31 | */
32 | package org.apache.http.nio;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/pool/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Client side connection pools APIs for asynchronous, event driven
30 | * communication.
31 | */
32 | package org.apache.http.nio.pool;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/protocol/MessageState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 | package org.apache.http.nio.protocol;
28 |
29 | enum MessageState {
30 |
31 | READY, INIT, ACK_EXPECTED, ACK, BODY_STREAM, COMPLETED
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Default implementations of HTTP connections for asynchronous,
30 | * even driven communication.
31 | */
32 | package org.apache.http.impl.nio;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Core HTTP entity implementations with support for
30 | * asynchronous, event driven communication.
31 | */
32 | package org.apache.http.nio.entity;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.reactor.ssl;
29 |
30 | /**
31 | * @since 4.2
32 | */
33 | public enum SSLMode {
34 |
35 | CLIENT,
36 | SERVER
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Default implementation of event driven network communication APIs
30 | * based on Java NIO.
31 | */
32 | package org.apache.http.impl.nio.reactor;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Default implementations of client side connection pools
30 | * for asynchronous, even driven communication.
31 | */
32 | package org.apache.http.impl.nio.pool;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Default implementations of message parses and writers
30 | * for asynchronous, even driven communication.
31 | */
32 | package org.apache.http.impl.nio.codecs;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/protocol/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Core HTTP protocol execution framework and HTTP protocol handlers
30 | * for asynchronous, event driven communication.
31 | */
32 | package org.apache.http.nio.protocol;
33 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.impl.nio.reactor;
29 |
30 | /**
31 | * @since 4.0
32 | *
33 | * @deprecated (4.2)
34 | */
35 | @Deprecated
36 | public enum SSLMode {
37 |
38 | CLIENT,
39 | SERVER
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/OoopsieRuntimeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http;
29 |
30 | public class OoopsieRuntimeException extends RuntimeException {
31 |
32 | private static final long serialVersionUID = 662807254163212266L;
33 |
34 | public OoopsieRuntimeException() {
35 | super("Ooopsie!!!");
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/NHttpConnectionFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import org.apache.http.nio.reactor.IOSession;
31 |
32 | /**
33 | * Factory for {@link NHttpConnection} instances.
34 | *
35 | * @since 4.2
36 | */
37 | public interface NHttpConnectionFactory {
38 |
39 | T createConnection(IOSession session);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/util/BufferInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.util;
29 |
30 | /**
31 | * Basic buffer properties.
32 | *
33 | * @since 4.0
34 | *
35 | * @deprecated (4.1) Use {@link org.apache.http.io.BufferInfo}
36 | */
37 | @Deprecated
38 | public interface BufferInfo {
39 |
40 | int length();
41 |
42 | int capacity();
43 |
44 | int available();
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionClosedCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.impl.nio.reactor;
29 |
30 | import org.apache.http.nio.reactor.IOSession;
31 |
32 | /**
33 | * Session callback interface used internally by I/O reactor implementations.
34 | *
35 | * @since 4.0
36 | */
37 | public interface SessionClosedCallback {
38 |
39 | void sessionClosed(IOSession session);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpsCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.impl.nio.reactor;
29 |
30 | /**
31 | * Callback interface used internally by I/O session implementations to delegate execution
32 | * of a {@link java.nio.channels.SelectionKey#interestOps(int)} operation to the I/O reactor.
33 | *
34 | * @since 4.1
35 | */
36 | interface InterestOpsCallback {
37 |
38 | void addInterestOps(InterestOpEntry entry);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointClosedCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.impl.nio.reactor;
29 |
30 | import org.apache.http.nio.reactor.ListenerEndpoint;
31 |
32 | /**
33 | * Listener endpoint callback interface used internally by I/O reactor
34 | * implementations.
35 | *
36 | * @since 4.0
37 | */
38 | public interface ListenerEndpointClosedCallback {
39 |
40 | void endpointClosed(ListenerEndpoint endpoint);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/NHttpMessageWriterFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import org.apache.http.HttpMessage;
31 | import org.apache.http.nio.reactor.SessionOutputBuffer;
32 |
33 | /**
34 | * Factory for {@link NHttpMessageWriter} instances.
35 | *
36 | * @since 4.3
37 | */
38 | public interface NHttpMessageWriterFactory {
39 |
40 | NHttpMessageWriter create(SessionOutputBuffer buffer);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | /**
29 | * Event driven network communication APIs loosely based on
30 | Doug Lea's
31 | reactor pattern.
32 |
33 | This API is not specific to HTTP communication. However, it is minimal
34 | in the sense that it defines only what is required within the scope
35 | of HTTP protocol.
36 | */
37 | package org.apache.http.nio.reactor;
38 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SocketAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.reactor;
29 |
30 | import java.net.Socket;
31 |
32 | /**
33 | * Provides access to the underlying Socket.
34 | *
35 | * Remark: this interface will be removed in the next major release.
36 | */
37 | public interface SocketAccessor {
38 |
39 | /**
40 | * Return the underlying socket
41 | *
42 | * @return - the underlying Socket, may be null.
43 | */
44 | Socket getSocket();
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/util/ByteBufferAllocator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.util;
29 |
30 | import java.nio.ByteBuffer;
31 |
32 | /**
33 | * Abstract interface to allocate {@link ByteBuffer} instances.
34 | *
35 | * @since 4.0
36 | */
37 | public interface ByteBufferAllocator {
38 |
39 | /**
40 | * Allocates {@link ByteBuffer} of the given size.
41 | *
42 | * @param size the size of the buffer.
43 | * @return byte buffer.
44 | */
45 | ByteBuffer allocate(int size);
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/NHttpMessageParserFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import org.apache.http.HttpMessage;
31 | import org.apache.http.config.MessageConstraints;
32 | import org.apache.http.nio.reactor.SessionInputBuffer;
33 |
34 | /**
35 | * Factory for {@link NHttpMessageParser} instances.
36 | *
37 | * @since 4.3
38 | */
39 | public interface NHttpMessageParserFactory {
40 |
41 | NHttpMessageParser create(SessionInputBuffer buffer, MessageConstraints constraints);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/pool/SocketAddressResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.pool;
29 |
30 | import java.io.IOException;
31 | import java.net.SocketAddress;
32 |
33 | /**
34 | * Strategy that resolves an abstract connection route to a local or a remote {@link SocketAddress}.
35 | * .
36 | * @since 4.3
37 | */
38 | public interface SocketAddressResolver {
39 |
40 | SocketAddress resolveLocalAddress(T route) throws IOException;
41 |
42 | SocketAddress resolveRemoteAddress(T route) throws IOException;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/pool/NIOConnFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.pool;
29 |
30 | import java.io.IOException;
31 |
32 | import org.apache.http.nio.reactor.IOSession;
33 |
34 | /**
35 | * Factory for poolable non-blocking connections.
36 | *
37 | * @param the route type that represents the opposite endpoint of a pooled
38 | * connection.
39 | * @param the connection type.
40 | * @since 4.2
41 | */
42 | public interface NIOConnFactory {
43 |
44 | C create(T route, IOSession session) throws IOException;
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingClientConnectionFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 | package org.apache.http.nio.testserver;
28 |
29 | import org.apache.http.impl.nio.DefaultNHttpClientConnection;
30 | import org.apache.http.nio.NHttpConnectionFactory;
31 | import org.apache.http.nio.reactor.IOSession;
32 |
33 | public class LoggingClientConnectionFactory implements NHttpConnectionFactory {
34 |
35 | public LoggingClientConnectionFactory() {
36 | super();
37 | }
38 |
39 | public DefaultNHttpClientConnection createConnection(final IOSession session) {
40 | return new LoggingNHttpClientConnection(session);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingServerConnectionFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 | package org.apache.http.nio.testserver;
28 |
29 | import org.apache.http.impl.nio.DefaultNHttpServerConnection;
30 | import org.apache.http.nio.NHttpConnectionFactory;
31 | import org.apache.http.nio.reactor.IOSession;
32 |
33 | public class LoggingServerConnectionFactory implements NHttpConnectionFactory {
34 |
35 | public LoggingServerConnectionFactory() {
36 | super();
37 | }
38 |
39 | public DefaultNHttpServerConnection createConnection(final IOSession session) {
40 | return new LoggingNHttpServerConnection(session);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/EventMask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.reactor;
29 |
30 | import java.nio.channels.SelectionKey;
31 |
32 | /**
33 | * Type of I/O event notifications I/O sessions can declare interest in.
34 | *
35 | * @since 4.0
36 | */
37 | public interface EventMask {
38 |
39 | /**
40 | * Interest in data input.
41 | */
42 | public static final int READ = SelectionKey.OP_READ;
43 |
44 | /**
45 | * Interest in data output.
46 | */
47 | public static final int WRITE = SelectionKey.OP_WRITE;
48 |
49 | /**
50 | * Interest in data input/output.
51 | */
52 | public static final int READ_WRITE = READ | WRITE;
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/util/HeapByteBufferAllocator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.util;
29 |
30 | import java.nio.ByteBuffer;
31 |
32 | import org.apache.http.annotation.Immutable;
33 |
34 | /**
35 | * Allocates {@link ByteBuffer} instances using
36 | * {@link ByteBuffer#allocate(int)}.
37 | *
38 | * @since 4.0
39 | */
40 | @Immutable
41 | public class HeapByteBufferAllocator implements ByteBufferAllocator {
42 |
43 | public static final HeapByteBufferAllocator INSTANCE = new HeapByteBufferAllocator();
44 |
45 | public HeapByteBufferAllocator() {
46 | super();
47 | }
48 |
49 | public ByteBuffer allocate(final int size) {
50 | return ByteBuffer.allocate(size);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/nio/testserver/SimpleIOReactorExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 | package org.apache.http.nio.testserver;
28 |
29 | import java.io.IOException;
30 |
31 | import org.apache.http.OoopsieRuntimeException;
32 | import org.apache.http.nio.reactor.IOReactorExceptionHandler;
33 |
34 | public class SimpleIOReactorExceptionHandler implements IOReactorExceptionHandler {
35 |
36 | public boolean handle(final RuntimeException ex) {
37 | if (!(ex instanceof OoopsieRuntimeException)) {
38 | ex.printStackTrace(System.out);
39 | }
40 | return false;
41 | }
42 |
43 | public boolean handle(final IOException ex) {
44 | ex.printStackTrace(System.out);
45 | return false;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/util/DirectByteBufferAllocator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.util;
29 |
30 | import java.nio.ByteBuffer;
31 |
32 | import org.apache.http.annotation.Immutable;
33 |
34 | /**
35 | * Allocates {@link ByteBuffer} instances using
36 | * {@link ByteBuffer#allocateDirect(int)}.
37 | *
38 | * @since 4.0
39 | */
40 | @Immutable
41 | public class DirectByteBufferAllocator implements ByteBufferAllocator {
42 |
43 | public static final DirectByteBufferAllocator INSTANCE = new DirectByteBufferAllocator();
44 |
45 | public DirectByteBufferAllocator() {
46 | super();
47 | }
48 |
49 | public ByteBuffer allocate(final int size) {
50 | return ByteBuffer.allocateDirect(size);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/IOReactorStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.reactor;
29 |
30 | /**
31 | * IOReactorStatus represents an internal status of an I/O reactor.
32 | *
33 | * @since 4.0
34 | */
35 | public enum IOReactorStatus {
36 |
37 | /**
38 | * The reactor is inactive / has not been started
39 | */
40 | INACTIVE,
41 |
42 | /**
43 | * The reactor is active / processing I/O events.
44 | */
45 | ACTIVE,
46 |
47 | /**
48 | * Shutdown of the reactor has been requested.
49 | */
50 | SHUTDOWN_REQUEST,
51 |
52 | /**
53 | * The reactor is shutting down.
54 | */
55 | SHUTTING_DOWN,
56 |
57 | /**
58 | * The reactor has shut down.
59 | */
60 | SHUT_DOWN
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/IOReactorException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.reactor;
29 |
30 | import java.io.IOException;
31 |
32 | /**
33 | * I/O exception that can be thrown by an I/O reactor. Usually exceptions
34 | * of this type are fatal and are not recoverable.
35 | *
36 | * @since 4.0
37 | */
38 | public class IOReactorException extends IOException {
39 |
40 | private static final long serialVersionUID = -4248110651729635749L;
41 |
42 | public IOReactorException(final String message, final Exception cause) {
43 | super(message);
44 | if (cause != null) {
45 | initCause(cause);
46 | }
47 | }
48 |
49 | public IOReactorException(final String message) {
50 | super(message);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/nio/integration/RndTestPatternGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.integration;
29 |
30 | import java.util.Random;
31 |
32 | final class RndTestPatternGenerator {
33 |
34 | private static final Random RND = new Random();
35 | private static final String TEST_CHARS = "0123456789ABCDEF";
36 |
37 | public static String generateText() {
38 | final StringBuilder buffer = new StringBuilder();
39 | for (int i = 0; i < 5; i++) {
40 | final char rndchar = TEST_CHARS.charAt(RND.nextInt(TEST_CHARS.length() - 1));
41 | buffer.append(rndchar);
42 | }
43 | return buffer.toString();
44 | }
45 |
46 | public static int generateCount(final int max) {
47 | return RND.nextInt(max - 1) + 1;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestHandlerMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.protocol;
29 |
30 | import org.apache.http.HttpRequest;
31 |
32 | /**
33 | * HttpAsyncRequestHandlerMapper can be used to resolve an instance
34 | * of {@link HttpAsyncRequestHandler} matching a particular {@link HttpRequest}.
35 | * Usually the resolved request handler will be used to process the request.
36 | *
37 | * @since 4.3
38 | */
39 | public interface HttpAsyncRequestHandlerMapper {
40 |
41 | /**
42 | * Looks up a handler matching the given request.
43 | *
44 | * @param request the request
45 | * @return HTTP request handler or null if no match
46 | * is found.
47 | */
48 | HttpAsyncRequestHandler> lookup(HttpRequest request);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionBufferStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 | package org.apache.http.nio.reactor;
28 |
29 | /**
30 | * SessionBufferStatus interface is intended to query the status of session
31 | * I/O buffers.
32 | *
33 | * @since 4.0
34 | */
35 | public interface SessionBufferStatus {
36 |
37 | /**
38 | * Determines if the session input buffer contains data.
39 | *
40 | * @return true if the session input buffer contains data,
41 | * false otherwise.
42 | */
43 | boolean hasBufferedInput();
44 |
45 | /**
46 | * Determines if the session output buffer contains data.
47 | *
48 | * @return true if the session output buffer contains data,
49 | * false otherwise.
50 | */
51 | boolean hasBufferedOutput();
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/SessionHttpContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.impl.nio;
29 |
30 | import org.apache.http.nio.reactor.IOSession;
31 | import org.apache.http.protocol.HttpContext;
32 |
33 | class SessionHttpContext implements HttpContext {
34 |
35 | private final IOSession iosession;
36 |
37 | public SessionHttpContext(final IOSession iosession) {
38 | super();
39 | this.iosession = iosession;
40 | }
41 |
42 | public Object getAttribute(final String id) {
43 | return this.iosession.getAttribute(id);
44 | }
45 |
46 | public Object removeAttribute(final String id) {
47 | return this.iosession.removeAttribute(id);
48 | }
49 |
50 | public void setAttribute(final String id, final Object obj) {
51 | this.iosession.setAttribute(id, obj);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/params/NIOReactorParamBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.params;
29 |
30 | import org.apache.http.params.HttpAbstractParamBean;
31 | import org.apache.http.params.HttpParams;
32 |
33 | /**
34 | * @since 4.0
35 | *
36 | * @deprecated (4.2) use {@link org.apache.http.impl.nio.reactor.IOReactorConfig}
37 | */
38 | @Deprecated
39 | public class NIOReactorParamBean extends HttpAbstractParamBean {
40 |
41 | public NIOReactorParamBean (final HttpParams params) {
42 | super(params);
43 | }
44 |
45 | public void setContentBufferSize (final int contentBufferSize) {
46 | NIOReactorParams.setContentBufferSize(params, contentBufferSize);
47 | }
48 |
49 | public void setSelectInterval (final long selectInterval) {
50 | NIOReactorParams.setSelectInterval(params, selectInterval);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLContextUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 | package org.apache.http.impl.nio;
28 |
29 | import javax.net.ssl.SSLContext;
30 | import java.security.NoSuchAlgorithmException;
31 |
32 | // TODO: to be replaced by SSLContext#getDefault() after upgrade to 1.6
33 | class SSLContextUtils {
34 |
35 | static SSLContext getDefault() {
36 | SSLContext sslcontext;
37 | try {
38 | try {
39 | sslcontext = SSLContext.getInstance("Default");
40 | } catch (NoSuchAlgorithmException ex) {
41 | sslcontext = SSLContext.getInstance("TLS");
42 | }
43 | sslcontext.init(null, null, null);
44 | } catch (final Exception ex) {
45 | throw new IllegalStateException("Failure initializing default SSL context", ex);
46 | }
47 | return sslcontext;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/NHttpRequestHandlerResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.protocol;
29 |
30 | /**
31 | * HttpRequestHandlerResolver can be used to resolve an instance of
32 | * {@link NHttpRequestHandler} matching a particular request URI. Usually the
33 | * resolved request handler will be used to process the request with the
34 | * specified request URI.
35 | *
36 | * @since 4.0
37 | *
38 | * @deprecated (4.2) use {@link HttpAsyncRequestHandlerResolver}
39 | */
40 | @Deprecated
41 | public interface NHttpRequestHandlerResolver {
42 |
43 | /**
44 | * Looks up a handler matching the given request URI.
45 | *
46 | * @param requestURI the request URI
47 | * @return HTTP request handler or null if no match
48 | * is found.
49 | */
50 | NHttpRequestHandler lookup(String requestURI);
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestHandlerResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.protocol;
29 |
30 | /**
31 | * HttpAsyncRequestHandlerResolver can be used to map an instance
32 | * of {@link HttpAsyncRequestHandler} matching a particular request URI.
33 | * Usually the mapped request handler will be used to process the request
34 | * with the specified request URI.
35 | *
36 | * @since 4.2
37 | * @deprecated see {@link HttpAsyncRequestHandlerMapper}
38 | */
39 | @Deprecated
40 | public interface HttpAsyncRequestHandlerResolver {
41 |
42 | /**
43 | * Looks up a handler matching the given request URI.
44 | *
45 | * @param requestURI the request URI
46 | * @return HTTP request handler or null if no match
47 | * is found.
48 | */
49 | HttpAsyncRequestHandler> lookup(String requestURI);
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/NHttpClientIOTarget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | /**
31 | * Extended version of the {@link NHttpClientConnection} used by
32 | * {@link org.apache.http.nio.reactor.IOEventDispatch} implementations
33 | * to inform client-side connection objects of I/O events.
34 | *
35 | * @since 4.0
36 | *
37 | * @deprecated (4.2) no longer used
38 | */
39 | @Deprecated
40 | public interface NHttpClientIOTarget extends NHttpClientConnection {
41 |
42 | /**
43 | * Triggered when the connection is ready to consume input.
44 | *
45 | * @param handler the client protocol handler.
46 | */
47 | void consumeInput(NHttpClientHandler handler);
48 |
49 | /**
50 | * Triggered when the connection is ready to produce output.
51 | *
52 | * @param handler the client protocol handler.
53 | */
54 | void produceOutput(NHttpClientHandler handler);
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/NHttpMessageWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import java.io.IOException;
31 |
32 | import org.apache.http.HttpException;
33 | import org.apache.http.HttpMessage;
34 |
35 | /**
36 | * Abstract HTTP message writer for non-blocking connections.
37 | *
38 | * @since 4.0
39 | */
40 | public interface NHttpMessageWriter {
41 |
42 | /**
43 | * Resets the writer. The writer will be ready to start serializing another
44 | * HTTP message.
45 | */
46 | void reset();
47 |
48 | /**
49 | * Serializes out the HTTP message head.
50 | *
51 | * @param message HTTP message.
52 | * @throws IOException in case of an I/O error.
53 | * @throws HttpException in case the HTTP message is malformed or
54 | * violates the HTTP protocol.
55 | */
56 | void write(T message) throws IOException, HttpException;
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/NHttpServerIOTarget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | /**
31 | * Extended version of the {@link NHttpServerConnection} used by
32 | * {@link org.apache.http.nio.reactor.IOEventDispatch } implementations
33 | * to inform server-side connection objects of I/O events.
34 | *
35 | * @since 4.0
36 | *
37 | * @deprecated (4.2) no longer used
38 | */
39 | @Deprecated
40 | public interface NHttpServerIOTarget extends NHttpServerConnection {
41 |
42 | /**
43 | * Triggered when the connection is ready to consume input.
44 | *
45 | * @param handler the server protocol handler.
46 | */
47 | void consumeInput(NHttpServiceHandler handler);
48 |
49 | /**
50 | * Triggered when the connection is ready to produce output.
51 | *
52 | * @param handler the server protocol handler.
53 | */
54 | void produceOutput(NHttpServiceHandler handler);
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/ContentDecoderChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import java.io.IOException;
31 | import java.nio.ByteBuffer;
32 | import java.nio.channels.ReadableByteChannel;
33 |
34 | /**
35 | * A {@link ReadableByteChannel} that delegates to a {@link ContentDecoder}.
36 | * Attempts to close this channel are ignored, and {@link #isOpen} always
37 | * returns true.
38 | *
39 | * @since 4.0
40 | */
41 | public class ContentDecoderChannel implements ReadableByteChannel {
42 |
43 | private final ContentDecoder decoder;
44 |
45 | public ContentDecoderChannel(final ContentDecoder decoder) {
46 | this.decoder = decoder;
47 | }
48 |
49 | public int read(final ByteBuffer dst) throws IOException {
50 | return decoder.read(dst);
51 | }
52 |
53 | public void close() {}
54 |
55 | public boolean isOpen() {
56 | return true;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/entity/ContentListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.entity;
29 |
30 | import java.io.IOException;
31 |
32 | import org.apache.http.nio.ContentDecoder;
33 | import org.apache.http.nio.IOControl;
34 |
35 | /**
36 | * A listener for available data on a non-blocking {@link ConsumingNHttpEntity}.
37 | *
38 | * @since 4.0
39 | *
40 | * @deprecated (4.2)
41 | */
42 | @Deprecated
43 | public interface ContentListener {
44 |
45 | /**
46 | * Notification that content is available to be read from the decoder.
47 | *
48 | * @param decoder content decoder.
49 | * @param ioctrl I/O control of the underlying connection.
50 | */
51 | void contentAvailable(ContentDecoder decoder, IOControl ioctrl)
52 | throws IOException;
53 |
54 | /**
55 | * Notification that any resources allocated for reading can be released.
56 | */
57 | void finished();
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/ContentEncoderChannel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import java.io.IOException;
31 | import java.nio.ByteBuffer;
32 | import java.nio.channels.WritableByteChannel;
33 |
34 | /**
35 | * A {@link WritableByteChannel} that delegates to a {@link ContentEncoder}.
36 | * Attempts to close this channel are ignored, and {@link #isOpen} always
37 | * returns true.
38 | *
39 | * @since 4.0
40 | */
41 | public class ContentEncoderChannel implements WritableByteChannel {
42 |
43 | private final ContentEncoder contentEncoder;
44 |
45 | public ContentEncoderChannel(final ContentEncoder contentEncoder) {
46 | this.contentEncoder = contentEncoder;
47 | }
48 |
49 | public int write(final ByteBuffer src) throws IOException {
50 | return contentEncoder.write(src);
51 | }
52 |
53 | public void close() {}
54 |
55 | public boolean isOpen() {
56 | return true;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentDecoderMock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.util;
29 |
30 | import java.io.IOException;
31 | import java.nio.ByteBuffer;
32 | import java.nio.channels.ReadableByteChannel;
33 |
34 | import org.apache.http.nio.ContentDecoder;
35 |
36 | public class ContentDecoderMock implements ContentDecoder {
37 |
38 | private final ReadableByteChannel channel;
39 | private boolean completed;
40 |
41 | public ContentDecoderMock(final ReadableByteChannel channel) {
42 | super();
43 | this.channel = channel;
44 | }
45 |
46 | public int read(final ByteBuffer dst) throws IOException {
47 | if (this.completed) {
48 | return -1;
49 | }
50 | final int bytesRead = this.channel.read(dst);
51 | if (bytesRead == -1) {
52 | this.completed = true;
53 | }
54 | return bytesRead;
55 | }
56 |
57 | public boolean isCompleted() {
58 | return this.completed;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExpectationVerifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.protocol;
29 |
30 | import java.io.IOException;
31 |
32 | import org.apache.http.HttpException;
33 | import org.apache.http.protocol.HttpContext;
34 |
35 | /**
36 | * HttpAsyncExpectationVerifier defines a strategy to verify whether
37 | * or not an incoming HTTP request meets the target server's expectations.
38 | *
39 | * A server that does not understand or is unable to comply with any of
40 | * the expectation values in the Expect field of a request MUST respond
41 | * with appropriate error status. The server MUST respond with a 417
42 | * (Expectation Failed) status if any of the expectations cannot be met
43 | * or, if there are other problems with the request, some other 4xx
44 | * status.
45 | *
46 | * @since 4.2
47 | */
48 | public interface HttpAsyncExpectationVerifier {
49 |
50 | void verify(
51 | HttpAsyncExchange httpExchange,
52 | HttpContext context) throws HttpException, IOException;
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentEncoderMock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.util;
29 |
30 | import java.io.IOException;
31 | import java.nio.ByteBuffer;
32 | import java.nio.channels.WritableByteChannel;
33 |
34 | import org.apache.http.impl.io.HttpTransportMetricsImpl;
35 | import org.apache.http.impl.nio.codecs.AbstractContentEncoder;
36 | import org.apache.http.nio.reactor.SessionOutputBuffer;
37 | import org.apache.http.util.Asserts;
38 |
39 | public class ContentEncoderMock extends AbstractContentEncoder {
40 |
41 | public ContentEncoderMock(
42 | final WritableByteChannel channel,
43 | final SessionOutputBuffer buffer,
44 | final HttpTransportMetricsImpl metrics) {
45 | super(channel, buffer, metrics);
46 | }
47 |
48 | public int write(final ByteBuffer src) throws IOException {
49 | if (src == null) {
50 | return 0;
51 | }
52 | Asserts.check(!isCompleted(), "Decoding process already completed");
53 | return this.channel.write(src);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionRequestHandle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.impl.nio.reactor;
29 |
30 | import org.apache.http.annotation.Immutable;
31 | import org.apache.http.util.Args;
32 |
33 | /**
34 | * Session request handle class used by I/O reactor implementations to keep
35 | * a reference to a {@link org.apache.http.nio.reactor.SessionRequest} along
36 | * with the time the request was made.
37 | *
38 | * @since 4.0
39 | */
40 | @Immutable
41 | public class SessionRequestHandle {
42 |
43 | private final SessionRequestImpl sessionRequest;
44 | private final long requestTime;
45 |
46 | public SessionRequestHandle(final SessionRequestImpl sessionRequest) {
47 | super();
48 | Args.notNull(sessionRequest, "Session request");
49 | this.sessionRequest = sessionRequest;
50 | this.requestTime = System.currentTimeMillis();
51 | }
52 |
53 | public SessionRequestImpl getSessionRequest() {
54 | return this.sessionRequest;
55 | }
56 |
57 | public long getRequestTime() {
58 | return this.requestTime;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/FileContentEncoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import java.io.IOException;
31 | import java.nio.channels.FileChannel;
32 |
33 | /**
34 | * A content encoder capable of transferring data directly from a {@link FileChannel}
35 | *
36 | * @since 4.0
37 | */
38 | public interface FileContentEncoder extends ContentEncoder {
39 |
40 | /**
41 | * Transfers a portion of entity content from the given file channel
42 | * to the underlying network channel.
43 | *
44 | * @param src the source FileChannel to transfer data from.
45 | * @param position
46 | * The position within the file at which the transfer is to begin;
47 | * must be non-negative
48 | * @param count
49 | * The maximum number of bytes to be transferred; must be
50 | * non-negative
51 | *@throws IOException, if some I/O error occurs.
52 | * @return The number of bytes, possibly zero,
53 | * that were actually transferred
54 | */
55 | long transfer(FileChannel src, long position, long count) throws IOException;
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/ContentDecoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio;
29 |
30 | import java.io.IOException;
31 | import java.nio.ByteBuffer;
32 |
33 | /**
34 | * Abstract HTTP content decoder. HTTP content decoders can be used
35 | * to read entity content from the underlying channel in small
36 | * chunks and apply the required coding transformation.
37 | *
38 | * @since 4.0
39 | */
40 | public interface ContentDecoder {
41 |
42 | /**
43 | * Reads a portion of content from the underlying channel
44 | *
45 | * @param dst The buffer into which entity content is to be transferred
46 | * @return The number of bytes read, possibly zero, or -1 if the
47 | * channel has reached end-of-stream
48 | * @throws IOException if I/O error occurs while reading content
49 | */
50 | int read(ByteBuffer dst) throws IOException;
51 |
52 | /**
53 | * Returns true if the entity has been received in its
54 | * entirety.
55 | *
56 | * @return true if all the content has been consumed,
57 | * false otherwise.
58 | */
59 | boolean isCompleted();
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/ExceptionEventTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.impl.nio.reactor;
29 |
30 | import java.util.Date;
31 |
32 | import org.junit.Assert;
33 | import org.junit.Test;
34 |
35 | public class ExceptionEventTest {
36 |
37 | @Test
38 | public void testGetCause() {
39 | final NullPointerException npe = new NullPointerException("npe");
40 | ExceptionEvent ee = new ExceptionEvent(npe);
41 | Assert.assertSame(npe, ee.getCause());
42 | ee = new ExceptionEvent(npe, new Date());
43 | Assert.assertSame(npe, ee.getCause());
44 | }
45 |
46 | @Test
47 | public void testGetTimestamp() {
48 | final NullPointerException npe = new NullPointerException("npe");
49 | ExceptionEvent ee = new ExceptionEvent(npe);
50 | Assert.assertNotNull(ee.getTimestamp());
51 | ee = new ExceptionEvent(npe, new Date(1234567890L));
52 | Assert.assertEquals(new Date(1234567890L), ee.getTimestamp());
53 | }
54 |
55 | @Test
56 | public void testToString() {
57 | Assert.assertNotNull(new ExceptionEvent(new NullPointerException()));
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/modules/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ====================================================================
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | * ====================================================================
20 | *
21 | * This software consists of voluntary contributions made by many
22 | * individuals on behalf of the Apache Software Foundation. For more
23 | * information on the Apache Software Foundation, please see
24 | * .
25 | *
26 | */
27 |
28 | package org.apache.http.nio.protocol;
29 |
30 | import org.apache.http.HttpRequest;
31 | import org.apache.http.HttpResponse;
32 | import org.apache.http.HttpStatus;
33 | import org.apache.http.entity.ContentType;
34 | import org.apache.http.nio.entity.NStringEntity;
35 | import org.apache.http.protocol.HttpContext;
36 |
37 | class NullRequestHandler implements HttpAsyncRequestHandler