Skip to content

Commit 83c4d6d

Browse files
authored
Merge pull request #36 from FusionAuth/degroff/file_manager_mainline
copy/merge in the FileManager and MultipartConfiguration changes from the maint. branch
2 parents e2a6e69 + ff2445b commit 83c4d6d

21 files changed

+938
-51
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Latest versions
44

5-
* Latest stable version: `1.0.0`
5+
* Latest stable version: `1.1.0`
66
* Now with 100% more virtual threads!
77
* Prior stable version `0.3.7`
88

@@ -27,20 +27,20 @@ To add this library to your project, you can include this dependency in your Mav
2727
<dependency>
2828
<groupId>io.fusionauth</groupId>
2929
<artifactId>java-http</artifactId>
30-
<version>1.0.0</version>
30+
<version>1.1.0</version>
3131
</dependency>
3232
```
3333

3434
If you are using Gradle, you can add this to your build file:
3535

3636
```groovy
37-
implementation 'io.fusionauth:java-http:1.0.0'
37+
implementation 'io.fusionauth:java-http:1.1.0'
3838
```
3939

4040
If you are using Savant, you can add this to your build file:
4141

4242
```groovy
43-
dependency(id: "io.fusionauth:java-http:1.0.0")
43+
dependency(id: "io.fusionauth:java-http:1.1.0")
4444
```
4545

4646
## Examples Usages:

build.savant

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ restifyVersion = "4.2.1"
1818
slf4jVersion = "2.0.17"
1919
testngVersion = "7.11.0"
2020

21-
project(group: "io.fusionauth", name: "java-http", version: "1.0.0", licenses: ["ApacheV2_0"]) {
21+
project(group: "io.fusionauth", name: "java-http", version: "1.1.0", licenses: ["ApacheV2_0"]) {
2222
workflow {
2323
fetch {
2424
// Dependency resolution order:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
/**
19+
* Thrown when a request exceeds the total configured maximum size.
20+
*
21+
* @author Daniel DeGroff
22+
*/
23+
public class ContentTooLargeException extends HTTPProcessingException {
24+
public long maximumRequestSize;
25+
26+
public ContentTooLargeException(long maximumRequestSize, String detailedMessage) {
27+
super(413, "Content Too Large", detailedMessage);
28+
this.maximumRequestSize = maximumRequestSize;
29+
}
30+
}

src/main/java/io/fusionauth/http/Cookie.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public Cookie(Cookie other) {
7474
return;
7575
}
7676

77+
this.attributes.putAll(other.attributes);
7778
this.domain = other.domain;
7879
this.expires = other.expires;
7980
this.httpOnly = other.httpOnly;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
/**
19+
* A base HTTP processing exception that is able to suggest a status code to return the client.
20+
*/
21+
public abstract class HTTPProcessingException extends RuntimeException {
22+
protected final int status;
23+
24+
protected final String statusMessage;
25+
26+
protected HTTPProcessingException(int status, String statusMessage) {
27+
this.status = status;
28+
this.statusMessage = statusMessage;
29+
}
30+
31+
protected HTTPProcessingException(int status, String statusMessage, String detailedMessage) {
32+
super(detailedMessage);
33+
this.status = status;
34+
this.statusMessage = statusMessage;
35+
}
36+
37+
public int getStatus() {
38+
return status;
39+
}
40+
41+
public String getStatusMessage() {
42+
return statusMessage;
43+
}
44+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
/**
19+
* Thrown when a multipart request cannot be parsed because a processor was not specified.
20+
*
21+
* @author Daniel DeGroff
22+
*/
23+
public class UnprocessableContentException extends HTTPProcessingException {
24+
public UnprocessableContentException(String message) {
25+
super(422, "Unprocessable Content", message);
26+
}
27+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http.io;
17+
18+
import java.io.IOException;
19+
import java.nio.file.Files;
20+
import java.nio.file.Path;
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
24+
/**
25+
* Manage file creation for multipart streams.
26+
*
27+
* @author Daniel DeGroff
28+
*/
29+
public class DefaultMultipartFileManager implements MultipartFileManager {
30+
private final String optionalPrefix;
31+
32+
private final String optionalSuffix;
33+
34+
private final Path tempDir;
35+
36+
private final List<Path> tempFiles = new ArrayList<>(0);
37+
38+
public DefaultMultipartFileManager(Path tempDir, String optionalPrefix, String optionalSuffix) {
39+
this.tempDir = tempDir;
40+
this.optionalPrefix = optionalPrefix;
41+
this.optionalSuffix = optionalSuffix;
42+
}
43+
44+
public Path createTemporaryFile() throws IOException {
45+
Path tempFile = Files.createTempFile(tempDir, optionalPrefix, optionalSuffix);
46+
tempFiles.add(tempFile);
47+
return tempFile;
48+
}
49+
50+
public List<Path> getTemporaryFiles() {
51+
return List.copyOf(tempFiles);
52+
}
53+
}

0 commit comments

Comments
 (0)