Skip to content

Commit ab51ec5

Browse files
committed
Small bug fixes
1 parent 864c4d2 commit ab51ec5

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Java Express Logo](https://image.ibb.co/mCdxtm/java_express.png)
22

3-
Small clone of the node-js express framework written in pure Java 8.
3+
44
[![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://choosealicense.com/licenses/mit/)
55

66
# Getting Started

src/express/http/request/RequestUtils.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.sun.net.httpserver.Headers;
44
import express.http.Cookie;
55

6+
import java.io.IOException;
7+
import java.io.UnsupportedEncodingException;
8+
import java.net.URLDecoder;
69
import java.util.HashMap;
710
import java.util.List;
811

@@ -41,7 +44,7 @@ protected static HashMap<String, Cookie> parseCookies(Headers headers) {
4144
* @param rawQuery The raw query
4245
* @return An list with key-values which are encoded in UTF8.
4346
*/
44-
protected static HashMap<String, String> parseRawQuery(String rawQuery) {
47+
protected static HashMap<String, String> parseRawQuery(String rawQuery) {
4548
HashMap<String, String> querys = new HashMap<>();
4649

4750
if (rawQuery == null)
@@ -59,7 +62,14 @@ protected static HashMap<String, String> parseRawQuery(String rawQuery) {
5962
if (c == '=')
6063
keyac = true;
6164
else if (c == '&') {
62-
querys.put(key.toString(), val.toString());
65+
66+
try {
67+
querys.put(URLDecoder.decode(key.toString(), "UTF-8"), URLDecoder.decode(val.toString(), "UTF8"));
68+
} catch (UnsupportedEncodingException e) {
69+
e.printStackTrace();
70+
// TODO: Handle error
71+
}
72+
6373
key.setLength(0);
6474
val.setLength(0);
6575
keyac = false;

src/express/http/response/Response.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ public Response setStatus(@NotNull Status status) {
9898
return this;
9999
}
100100

101+
/**
102+
* Set the response-status and send the response.
103+
*
104+
* @param status The response status.
105+
*/
106+
public void sendStatus(@NotNull Status status) {
107+
if (checkIfClosed()) return;
108+
this.status = status.getCode();
109+
send();
110+
}
111+
101112
/**
102113
* @return The current contentType
103114
*/

0 commit comments

Comments
 (0)