-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide wrappers for Jakarta and Java EE
- Loading branch information
Showing
27 changed files
with
1,027 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
core/src/main/java/org/matomo/java/tracking/servlet/CookieWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.matomo.java.tracking.servlet; | ||
|
||
import lombok.Value; | ||
|
||
/** | ||
* Wrapper for the cookie name and value. | ||
*/ | ||
@Value | ||
public class CookieWrapper { | ||
|
||
String name; | ||
|
||
String value; | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
core/src/main/java/org/matomo/java/tracking/servlet/HttpServletRequestWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.matomo.java.tracking.servlet; | ||
|
||
import edu.umd.cs.findbugs.annotations.Nullable; | ||
import java.util.Collections; | ||
import java.util.Enumeration; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import lombok.Builder; | ||
import lombok.NonNull; | ||
import lombok.Value; | ||
|
||
/** | ||
* Wraps a HttpServletRequest to be compatible with both the Jakarta and the Java EE API. | ||
*/ | ||
@Builder | ||
@Value | ||
public class HttpServletRequestWrapper { | ||
|
||
StringBuffer requestURL; | ||
|
||
String remoteAddr; | ||
|
||
Map<String, String> headers; | ||
|
||
CookieWrapper[] cookies; | ||
|
||
/** | ||
* Returns an enumeration of all the header names this request contains. If the request has no | ||
* headers, this method returns an empty enumeration. | ||
* | ||
* @return an enumeration of all the header names sent with this request | ||
*/ | ||
public Enumeration<String> getHeaderNames() { | ||
return headers == null ? Collections.emptyEnumeration() : | ||
Collections.enumeration(headers.keySet()); | ||
} | ||
|
||
/** | ||
* Returns the value of the specified request header as a String. If the request did not include a | ||
* header of the specified name, this method returns null. If there are multiple headers with the | ||
* same name, this method returns the last header in the request. The header name is case | ||
* insensitive. You can use this method with any request header. | ||
* | ||
* @param name a String specifying the header name (case insensitive) - must not be {@code null}. | ||
* @return a String containing the value of the requested header, or null if the request does not | ||
* have a header of that name | ||
*/ | ||
@Nullable | ||
public String getHeader(@NonNull String name) { | ||
return headers == null ? null : headers.get(name.toLowerCase(Locale.ROOT)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.