-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement getCookies, getLocalPort, and getLocalAddr methods in RequestWrapper #6
Comments
Thank you for your comments. I am looking forward to your PRs. Please add units tests where possible. |
Created a jira issue for secondary tracking ACCCESS-1 |
Thank you. I'll try it. |
I found a issue while considering tests for |
@ceki Thank you so much. But, I have a exception.
I would suggest using toArray with a type instead. diff --git a/jetty12/src/main/java/ch/qos/logback/access/jetty/RequestWrapper.java b/jetty12/src/main/java/ch/qos/logback/access/jetty/RequestWrapper.java
index b5d390c..309a441 100644
--- a/jetty12/src/main/java/ch/qos/logback/access/jetty/RequestWrapper.java
+++ b/jetty12/src/main/java/ch/qos/logback/access/jetty/RequestWrapper.java
@@ -65,7 +65,7 @@ public class RequestWrapper implements HttpServletRequest, WrappedHttpRequest {
List<Cookie> cookieList = httpCookies.stream().map(httpCookie -> new Cookie(httpCookie.getName(), httpCookie.getValue())).collect(
Collectors.toList());
- return (Cookie[]) cookieList.toArray();
+ return cookieList.toArray(new Cookie[cookieList.size()]);
}
@Override |
All three are working fine in logback-access version 2.0.2. |
@ceki It looks like this issue has been resolved, so could you please process the closing. |
Logback Access 2.0.1 and Jetty 12.
The methods getCookies, getLocalPort, and getLocalAddr currently exist within the RequestWrapper class but do not return meaningful data as one might expect.
These methods will be used in my project and I expect to improve them.
Moreover, the improvements to getCookies and getLocalPort methods are useful as they correlate with the values used in logback-access's pattern layouts, such as
%reqCookie
for cookies and%localPort
for the local port. (For some reason,%localIP
works without the getLocalAddr implementation.I propose the following changes:
getCookies()
: This method should be improved to convert and return an array ofCookie
objects, derived from theList<HttpCookie>
returned byRequest::getCookies
.getLocalPort()
: By usingRequest::getLocalPort
, this method could be improved to return the port number.getLocalAddr()
: Similarly by usingRequest::getLocalAddr
, this method could be improved to return the local address.The text was updated successfully, but these errors were encountered: