-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new annotation and an interceptor to control and check content … #36
Conversation
…size of bodies and files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faudrait aussi ajouter une documentation dans le fichier README.md
du module pour expliquer comment l'utiliser
plume-web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentSizeLimit.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
plume-web-jersey/src/test/java/com/coreoz/plume/jersey/control/ContentSizeLimitTest.java
Outdated
Show resolved
Hide resolved
… size provided by the annotation
… header is already higher than the limit
c7b35bb
to
e654911
Compare
e654911
to
f6a9e0f
Compare
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
...web-jersey/src/main/java/com/coreoz/plume/jersey/security/control/ContentControlFeature.java
Outdated
Show resolved
Hide resolved
plume-web-jersey/src/test/java/com/coreoz/plume/jersey/control/TestContentSizeResource.java
Show resolved
Hide resolved
52ed253
to
295ce44
Compare
Integer headerContentLength; | ||
try { | ||
headerContentLength = Integer.parseInt(context.getHeaders().getFirst(HttpHeaders.CONTENT_LENGTH)); | ||
} catch (NumberFormatException e) { | ||
headerContentLength = maxSize; // default value for GET or chunked body | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est un peu cracra, tu vas lever des exceptions à chaque requête GET.
Ce serait mieux de faire le parsing seulement si le header est non nul.
Par exemple :
Integer headerContentLength; | |
try { | |
headerContentLength = Integer.parseInt(context.getHeaders().getFirst(HttpHeaders.CONTENT_LENGTH)); | |
} catch (NumberFormatException e) { | |
headerContentLength = maxSize; // default value for GET or chunked body | |
} | |
int headerContentLength = maxSize; // default value for GET or chunked body | |
String contentLengthHeader = context.getHeaders().getFirst(HttpHeaders.CONTENT_LENGTH); | |
if (contentLengthHeader) { | |
try { | |
headerContentLength = Integer.parseInt(contentLengthHeader); | |
} catch (NumberFormatException e) { | |
logger.warn("Wrong content length header received: {}", contentLengthHeader); | |
} | |
} |
Quality Gate passedIssues Measures |
…size of bodies and files
Will need an update after jersey migration to jakarta