Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented raw response body control.
- Loading branch information
1 parent
99d1942
commit a7986c3
Showing
5 changed files
with
116 additions
and
9 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
58 changes: 58 additions & 0 deletions
58
rapidoid-integration-tests/src/test/java/org/rapidoid/http/HttpRawResponseTest.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,58 @@ | ||
package org.rapidoid.http; | ||
|
||
/* | ||
* #%L | ||
* rapidoid-integration-tests | ||
* %% | ||
* Copyright (C) 2014 - 2015 Nikolche Mihajlovski and contributors | ||
* %% | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import org.junit.Test; | ||
import org.rapidoid.annotation.Authors; | ||
import org.rapidoid.annotation.Since; | ||
import org.rapidoid.http.fast.On; | ||
import org.rapidoid.http.fast.ReqHandler; | ||
import org.rapidoid.util.Bufs; | ||
|
||
@Authors("Nikolche Mihajlovski") | ||
@Since("5.0.10") | ||
public class HttpRawResponseTest extends HttpTestCommons { | ||
|
||
@Test | ||
public void testBytesResponse() { | ||
On.get("/bytes").html(new ReqHandler() { | ||
@Override | ||
public Object handle(Req req) throws Exception { | ||
return req.response().body("ABC".getBytes()); | ||
} | ||
}); | ||
|
||
testGet("/bytes"); | ||
} | ||
|
||
@Test | ||
public void testByteBufferResponse() { | ||
On.get("/buf").json(new ReqHandler() { | ||
@Override | ||
public Object handle(Req req) throws Exception { | ||
return req.response().body(Bufs.buf("{\"byte-buffer\": true}")); | ||
} | ||
}); | ||
|
||
testGet("/buf"); | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
rapidoid-integration-tests/src/test/resources/results/HttpRawResponseTest/GET_buf
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,8 @@ | ||
HTTP/1.1 200 OK | ||
Connection: keep-alive | ||
Server: Rapidoid | ||
Date: XXXXX GMT | ||
Content-Type: application/json; charset=utf-8 | ||
Content-Length: 21 | ||
|
||
{"byte-buffer": true} |
8 changes: 8 additions & 0 deletions
8
rapidoid-integration-tests/src/test/resources/results/HttpRawResponseTest/GET_bytes
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,8 @@ | ||
HTTP/1.1 200 OK | ||
Connection: keep-alive | ||
Server: Rapidoid | ||
Date: XXXXX GMT | ||
Content-Type: text/html; charset=utf-8 | ||
Content-Length: 3 | ||
|
||
ABC |