-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #806 from micronaut-projects/andriy/poja-improve
Improve POJA implementation
- Loading branch information
Showing
11 changed files
with
100 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
http-poja-apache/src/test/groovy/io/micronaut/http/poja/SimpleServerFailedParseSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.micronaut.http.poja | ||
|
||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import spock.lang.Specification | ||
import spock.lang.Stepwise | ||
|
||
@Stepwise | ||
@MicronautTest | ||
class SimpleServerFailedParseSpec extends Specification { | ||
|
||
@Inject | ||
SimpleServerSpec.StringTestingClient client | ||
|
||
void "test non-parseable GET method"() { | ||
when: | ||
var response = client.exchange(SimpleServerSpec.unindent(""" | ||
GET /test HTTP/1.1error\r | ||
Host: h\r | ||
\r | ||
""")) | ||
|
||
then: | ||
response == SimpleServerSpec.unindent(""" | ||
HTTP/1.1 400 Bad Request\r | ||
Content-Length: 32\r | ||
Content-Type: text/plain\r | ||
\r | ||
HTTP request could not be parsed""") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
http-poja-common/src/main/java/io/micronaut/http/poja/exception/NoPojaRequestException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2017-2024 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.http.poja.exception; | ||
|
||
/** | ||
* An exception to be thrown when no additional requests can be parsed. | ||
* This can happen if the input stream is closed when waiting for a new request. | ||
* This is not an error condition, therefore application can simply stop. | ||
*/ | ||
public class NoPojaRequestException extends RuntimeException { | ||
|
||
/** | ||
* Constructor for the exception. | ||
*/ | ||
public NoPojaRequestException() { | ||
super("No new request was found in the input stream"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
GET / HTTP/1.1 | ||
Content-Length: 0 | ||
|