-
Notifications
You must be signed in to change notification settings - Fork 82
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
XSD download fails with "Server returned HTTP response code: 403" #429
XSD download fails with "Server returned HTTP response code: 403" #429
Comments
Hello! I can't seem to reproduce the issue. I have a few questions that might help to pin down the issue. Does this happen every time you open the document, or just once? Are you behind a proxy for internet access? Are you running the binary or the Java version of the server? |
If I close and reopen the document, it doesn't seem to attempt the download again, it only logs "Ignored unavailable schema...". Reloading VSCode triggers the entire output channel sequence from above.
No.
Whatever the default is I guess? I just installed it from the VSCode marketplace and haven't configured anything in |
Okay. Thanks for the information. I can't seem to reproduce the issue. Are you using the default settings for vscode-xml? Would you be able to search for "LemMinX Server info:" in the XML Support output, then copy and paste the list of infos? |
Yes, as I said.
|
Okay. Thank you! |
I'm able to reproduce now. |
Under Java 11, I didn't get the bug, but under Java 8 in Windows and Linux I get the same thing. |
That's interesting. I'm not even sure how it ends up using that JDK 8, the one in my PATH is a JDK 14. If I set |
Problem comes from with URLConnection use https://github.com/eclipse/lemminx/blob/a54317a7490f35a3fd34a2acd70f94fc5ce289e8/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/uriresolver/CacheResourcesManager.java#L169 The problem can be reproduced easily with a simple main: package test;
import java.net.URL;
import java.net.URLConnection;
public class Main {
public static void main(String[] args) throws Exception {
String actualURI = "https://lime.software/xsd/project-1.0.0.xsd";
URL url = new URL(actualURI);
URLConnection conn = url.openConnection();
conn.getInputStream();
}
} If you execute this code in Java 11 it's working although in Java 1.8 it throws a 403 error. It's seems that it's a user agent request matter. In Java 8, the user agent is You can experiment that with the following code executed in Java 1.8: package test;
import java.net.URL;
import java.net.URLConnection;
public class Main {
public static void main(String[] args) throws Exception {
String actualURI = "https://lime.software/xsd/project-1.0.0.xsd";
URL url = new URL(actualURI);
URLConnection conn = url.openConnection();
conn.addRequestProperty("User-Agent", "Java/1.8"); // throws a 403
conn.getInputStream();
}
} should throw a 403, although the following code should work: package test;
import java.net.URL;
import java.net.URLConnection;
public class Main {
public static void main(String[] args) throws Exception {
String actualURI = "https://lime.software/xsd/project-1.0.0.xsd";
URL url = new URL(actualURI);
URLConnection conn = url.openConnection();
conn.addRequestProperty("User-Agent", "Java/11"); // should work
conn.getInputStream();
}
} A fix could catch the 403 error and recreate the connection by forcing the User Agent like |
No don't catch the 403. always set the user agent to LemMinX. That'll take care of downloading files hosted on cloudflare managed servers |
:| |
Closes redhat-developer/vscode-xml#429 Signed-off-by: David Thompson <[email protected]>
Closes redhat-developer/vscode-xml#429 Signed-off-by: David Thompson <[email protected]>
Closes redhat-developer/vscode-xml#429 Signed-off-by: David Thompson <[email protected]>
Causes the following error output in the XML output channel:
The 403 error response is very curious, as I have no issues viewing https://lime.software/xsd/project-1.0.0.xsd in my browser.
curl https://lime.software/xsd/project-1.0.0.xsd
also has no complaints.VSCode 1.53.2, Windows 10 20H2, vscode-xml 0.15.0
The text was updated successfully, but these errors were encountered: