forked from eclipse-lemminx/lemminx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use User-Agent "LemMinX" when downloading schemas
Closes redhat-developer/vscode-xml#429 Signed-off-by: David Thompson <[email protected]>
- Loading branch information
Showing
3 changed files
with
57 additions
and
15 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
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
40 changes: 40 additions & 0 deletions
40
...clipse.lemminx/src/test/java/org/eclipse/lemminx/uriresolver/ModifiedResourceHandler.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,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.uriresolver; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.handler.ResourceHandler; | ||
|
||
public class ModifiedResourceHandler extends ResourceHandler { | ||
|
||
public ModifiedResourceHandler() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) | ||
throws IOException, ServletException { | ||
|
||
// 403 if user agent starts with Java/1. | ||
if (request.getHeader("User-Agent").indexOf("Java/1.") == 0) { | ||
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Java 8 is not allowed"); | ||
return; | ||
} | ||
|
||
super.handle(target, baseRequest, request, response); | ||
} | ||
|
||
} |