Package org.gitlab4j.api.utils
Class HttpRequestUtils
java.lang.Object
org.gitlab4j.api.utils.HttpRequestUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getPostDataAsString
(javax.servlet.http.HttpServletRequest request) Reads the POST data from a request into a String and returns it.static String
getReaderContentAsString
(Reader reader) Reads the content of a Reader instance and returns it as a String.static String
getRequestDump
(String fromMethod, javax.servlet.http.HttpServletRequest request, boolean includePostData) Build a String containing a multi-line dump of an HTTP request.static String
getShortRequestDump
(String fromMethod, boolean includeHeaders, javax.servlet.http.HttpServletRequest request) Build a String containing a short multi-line dump of an HTTP request.static String
getShortRequestDump
(String fromMethod, javax.servlet.http.HttpServletRequest request) Build a String containing a very short multi-line dump of an HTTP request.static String
Masks the PRIVATE-TOKEN header value with "********".
-
Constructor Details
-
HttpRequestUtils
public HttpRequestUtils()
-
-
Method Details
-
getShortRequestDump
public static String getShortRequestDump(String fromMethod, javax.servlet.http.HttpServletRequest request) Build a String containing a very short multi-line dump of an HTTP request.- Parameters:
fromMethod
- the method that this method was called fromrequest
- the HTTP request build the request dump from- Returns:
- a String containing a very short multi-line dump of the HTTP request
-
getShortRequestDump
public static String getShortRequestDump(String fromMethod, boolean includeHeaders, javax.servlet.http.HttpServletRequest request) Build a String containing a short multi-line dump of an HTTP request.- Parameters:
fromMethod
- the method that this method was called fromrequest
- the HTTP request build the request dump fromincludeHeaders
- if true will include the HTTP headers in the dump- Returns:
- a String containing a short multi-line dump of the HTTP request
-
getRequestDump
public static String getRequestDump(String fromMethod, javax.servlet.http.HttpServletRequest request, boolean includePostData) Build a String containing a multi-line dump of an HTTP request.- Parameters:
fromMethod
- the method that this method was called fromrequest
- the HTTP request build the request dump fromincludePostData
- if true will include the POST data in the dump- Returns:
- a String containing a multi-line dump of the HTTP request, If an error occurs, the message from the exception will be returned
-
getPostDataAsString
public static String getPostDataAsString(javax.servlet.http.HttpServletRequest request) throws IOException Reads the POST data from a request into a String and returns it.- Parameters:
request
- the HTTP request containing the POST data- Returns:
- the POST data as a String instance
- Throws:
IOException
- if any error occurs while reading the POST data
-
getReaderContentAsString
Reads the content of a Reader instance and returns it as a String.- Parameters:
reader
- the Reader instance to read the data from- Returns:
- the content of a Reader instance as a String
- Throws:
IOException
- if any error occurs while reading the POST data
-
maskPrivateToken
Masks the PRIVATE-TOKEN header value with "********".- Parameters:
s
- a String containing HTTP request info, usually logging info- Returns:
- a String with the PRIVATE-TOKEN header value masked with asterisks
-