Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
smthing committed Aug 15, 2024
1 parent 760b894 commit 46b3155
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import jakarta.servlet.http.MappingMatch;
import jakarta.servlet.http.Part;
import org.smartboot.http.common.enums.HeaderNameEnum;
import org.smartboot.http.common.enums.HeaderValueEnum;
import org.smartboot.http.common.logging.Logger;
import org.smartboot.http.common.logging.LoggerFactory;
import org.smartboot.http.common.utils.NumberUtils;
Expand Down Expand Up @@ -447,10 +448,13 @@ public Collection<Part> getParts() throws IOException, ServletException {
private Collection<Part> parts = null;
private Exception partsParseException = null;

private void parseParts() {
private void parseParts() throws ServletException {
if (parts != null || partsParseException != null) {
return;
}
if (!request.getContentType().startsWith(HeaderValueEnum.MULTIPART_FORM_DATA.getName())) {
throw new ServletException("Not a multipart request");
}
try {
MultipartConfigElement multipartConfigElement = servletInfo.getMultipartConfig();
if (multipartConfigElement == null) {
Expand Down Expand Up @@ -480,7 +484,12 @@ private void parseParts() {
String name = part.getName();
String value = null;
try {
value = item.getString(getCharacterEncoding());
if (StringUtils.isBlank(getCharacterEncoding())) {
value = item.getString();
} else {
value = item.getString(getCharacterEncoding());
}

} catch (UnsupportedEncodingException uee) {
// Not possible
}
Expand Down

0 comments on commit 46b3155

Please sign in to comment.