Skip to content
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

java.io.IOException: Server returned HTTP response code: 400 #66

Closed
mcprol opened this issue Oct 15, 2022 · 7 comments
Closed

java.io.IOException: Server returned HTTP response code: 400 #66

mcprol opened this issue Oct 15, 2022 · 7 comments
Labels

Comments

@mcprol
Copy link

mcprol commented Oct 15, 2022

Question

Hi,
I'm getting this error when try to upload a file to Cloudflare servers:
java.io.IOException: Server returned HTTP response code: 400

It seems that the root cause is the following code, at TusUploader.java file
try {
connection.setRequestMethod("PATCH");
// Check whether we are running on a buggy JRE
} catch (java.net.ProtocolException pe) {
connection.setRequestMethod("POST");
connection.setRequestProperty("X-HTTP-Method-Override", "PATCH");
}

Cloudflare does not support the X-HTTP-Method-Override header.

I have found the same error at:
#29

Is there any workaround does not depends on server configuration?

Regards
Marcos

Setup details
Please provide following details, if applicable to your situation:

  • Runtime environment: OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1)
  • Used tus-java-client version: v0.4.5
  • Used tus server software: cloudflare
@Acconut
Copy link
Member

Acconut commented Oct 16, 2022

If you are working in an environment, which does not support sending PATCH requests, and with a server, which does not allow to override the request method, then I do not think there is a solution to this.

Can you please test whether your Java environment is able to send PATCH requests? If not, please contact Cloudflare and ask them for help as you are using their servers.

@mcprol
Copy link
Author

mcprol commented Oct 16, 2022

Hi,
I have open a request to Cloudflare to support the X-HTTP-Method-Override attribute.

In the other hand, I have found a workaround (https://community.hubspot.com/t5/APIs-Integrations/Invalid-HTTP-method-PATCH/m-p/436679) to make the PATCH verb to work in jdk11, but not in above versions.

I think the problem is that tus-java-client is using HttpUrlConnection class, and it should be move to another http client.

Thank you for your response.
I'm closing this issue.

Marcos

@mcprol mcprol closed this as completed Oct 16, 2022
@Acconut
Copy link
Member

Acconut commented Oct 18, 2022

I think the problem is that tus-java-client is using HttpUrlConnection class, and it should be move to another http client.

You are correct. We have talked about using another HTTP client in #14 and want to work on this in the near future. Your feedback is very helpful for prioritizing this work.

@fujohnwang
Copy link

encounter same problem

@Acconut
Copy link
Member

Acconut commented Dec 5, 2022

@fujohnwang Are you uploading to CloudFlare as well?

@fujohnwang
Copy link

@fujohnwang Are you uploading to CloudFlare as well?

yes

I bypass via some nasty hacking, but it works, and I wrote a blog on this, but in Chinese, Hope it helps if you can figure out via the code part, the blog is here:

http://afoo.me/posts/2022-12-06-tus-stuck-in-cloudflare-stream.html

just pay attention to the java reflection part and cli/VM options part.

@Acconut
Copy link
Member

Acconut commented Jan 17, 2023

Thank you, @fujohnwang. The way I understand it is that the current HTTP client inside tus-java-client is not fully compatible with CloudFlare. We will upgrade to a newer HTTP client in the next major release: #78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants