Gitlab Community Edition Instance

Commit 417d99da authored by mhellka's avatar mhellka
Browse files

Whitespace

parent 776c3b50
Pipeline #111689 failed with stage
in 2 minutes and 56 seconds
......@@ -72,7 +72,7 @@ public interface RestConfig {
/**
* Create and return a nested {@link RestConfig}.
*
* @param Listen to requests for this path (relativ e to the parent
* @param Listen to requests for this path (relative to the parent
* configuration). Null or an empty string are translated to '/'.
* @param inherit If true, inherit response and error mappers as well as
* services from the parent.
......
......@@ -22,7 +22,8 @@ import org.slf4j.LoggerFactory;
import de.gwdg.cdstar.Utils;
/**
* Filter to add CORS simple-request headers and handle CORS preflight requests.
* Filter to add CORS simple-request headers and handle CORS pre-flight
* requests.
*
* By default, allow all origins. The Access-Control-Allow-Credentials header is
* NOT set, so clients are forced to set the Authorization header manually and
......@@ -47,7 +48,7 @@ public class CORSFilter implements Filter {
// TODO: Find a way for plugins to add their headers and settings to this filter
final List<String> tusHeaders = Arrays.asList("Upload-Offset", "Upload-Length", "Tus-Version", "Tus-Resumable",
"Tus-Extension", "Tus-Max-Size", "Upload-Metadata");
"Tus-Extension", "Tus-Max-Size", "Upload-Metadata");
allow.addAll(tusHeaders);
expose.addAll(tusHeaders);
......@@ -75,7 +76,7 @@ public class CORSFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
throws IOException, ServletException {
final HttpServletRequest rq = (HttpServletRequest) request;
final HttpServletResponse rs = (HttpServletResponse) response;
......@@ -83,12 +84,11 @@ public class CORSFilter implements Filter {
if (origin != null) {
if (log.isDebugEnabled())
log.debug("CORS request (origin={}, client={}, method={}, path={})",
Utils.repr(origin), rq.getRemoteAddr(), rq.getMethod(), rq.getPathInfo());
log.debug("CORS request (origin={}, client={}, method={}, path={})", Utils.repr(origin),
rq.getRemoteAddr(), rq.getMethod(), rq.getPathInfo());
// CORS pre-flight request
if ("OPTIONS".equals(rq.getMethod()) &&
rq.getHeader("Access-Control-Request-Method") != null) {
if ("OPTIONS".equals(rq.getMethod()) && rq.getHeader("Access-Control-Request-Method") != null) {
rs.setHeader("Access-Control-Allow-Origin", "*");
rs.setHeader("Access-Control-Max-Age", maxAge);
rs.setHeader("Access-Control-Allow-Methods", allowMethods);
......
......@@ -4,7 +4,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
......@@ -41,12 +40,12 @@ public class RestUtils {
/**
* Set `ETag` and `Last-Modified` response headers and check them against
* `If-Match`, `If-None-Match`, `If-Modified-Since` and
* `If-Unmodified-Since` request headers. Return true if this request should
* be answered with a full response, false if no response body is required.
* `If-Match`, `If-None-Match`, `If-Modified-Since` and `If-Unmodified-Since`
* request headers. Return true if this request should be answered with a full
* response, false if no response body is required.
*
* In the later case, the response status code is already set to either 403
* or 412.
* In the later case, the response status code is already set to either 403 or
* 412.
*/
public static boolean checkConditional(RestContext ctx, Date lastModified, String etag) {
ctx.header("ETag", etag);
......@@ -148,8 +147,8 @@ public class RestUtils {
/**
* Parse an URL-encoded query string (e.g. 'key=value&amp;...') into a
* multi-valued map. Order of values for a given key is preserved, but keys
* are not ordered (since the returned map is not ordered).
* multi-valued map. Order of values for a given key is preserved, but keys are
* not ordered (since the returned map is not ordered).
*
* Parameter names and values may be empty strings. The '=' separator is
* optional if the value is empty, but required if the key is also empty.
......@@ -171,7 +170,7 @@ public class RestUtils {
} else if (c == '&') {
if (key != null) {
params.computeIfAbsent(urlDecode(key), k -> new ArrayList<>(1))
.add(urlDecode(rawQuery.substring(o, i)));
.add(urlDecode(rawQuery.substring(o, i)));
key = null;
} else if (i > o) {
params.computeIfAbsent(urlDecode(rawQuery.substring(o, i)), k -> new ArrayList<>(1)).add("");
......@@ -210,19 +209,16 @@ public class RestUtils {
} catch (final JsonParseException e) {
log.debug("Failed to parse request body", e);
throw new ErrorResponse(400, "JsonParseError", "Invalid JSON response body")
.detail("line", e.getLocation().getLineNr())
.detail("column", e.getLocation().getColumnNr())
.cause(e);
.detail("line", e.getLocation().getLineNr()).detail("column", e.getLocation().getColumnNr())
.cause(e);
} catch (final JsonMappingException e) {
log.debug("Failed to map request body (target={})", klass, e);
throw new ErrorResponse(400, "JsonMappingError", "JSON request did not match expected structure")
.detail("line", e.getLocation().getLineNr())
.detail("column", e.getLocation().getColumnNr())
.cause(e);
.detail("line", e.getLocation().getLineNr()).detail("column", e.getLocation().getColumnNr())
.cause(e);
} catch (final IOException e) {
log.debug("JsonMappingException", e);
throw new ErrorResponse(400, "IOError", "Failed to read request body")
.cause(e);
throw new ErrorResponse(400, "IOError", "Failed to read request body").cause(e);
}
} else {
throw new ErrorResponse(415, "UnsupportedMediaType", "Expected application/json request");
......
......@@ -8,17 +8,15 @@ import java.util.List;
*/
public interface FormParser {
ByteBuffer EOF = ByteBuffer.allocate(0);
/**
* Parse some bytes and return a list of zero or more {@link FormPart}
* instances. The last element in a list may be incomplete, so always check
* {@link FormPart#isComplete()}.
* Parse all remaining bytes from this buffer and return a list of zero or more
* {@link FormPart} instances. The last element in the result list may be
* incomplete, so make sure to check {@link FormPart#isComplete()}.
*/
List<FormPart> parse(ByteBuffer bytes) throws Exception;
List<FormPart> parse(ByteBuffer bytes) throws Exception;
/**
/**
* Return any buffered {@link FormPart}s and close the parser.
*/
List<FormPart> finish() throws Exception;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment