-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Enforce Content-Type requirement on the rest layer and remove deprecated methods #23146
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0d1c861
Enforce Content-Type requirement on the rest layer and remove depreca…
jaymode e5ed488
update docs
jaymode 40e211a
Merge branch 'master' into content_type_rest
jaymode 5ed36ce
Merge branch 'master' into content_type_rest
jaymode f735b31
Merge branch 'master' into content_type_rest
jaymode e6d7c2b
Merge branch 'master' into content_type_rest
jaymode e379b6a
clean up forbidden api changes
jaymode 7fb9656
update docs
jaymode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,45 @@ | ||
# Licensed to Elasticsearch under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch licenses this file to you under | ||
# the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on | ||
# an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
# either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
|
||
@defaultMessage Explicitly specify the ContentType of HTTP entities when creating | ||
org.apache.http.entity.StringEntity#<init>(java.lang.String) | ||
org.apache.http.entity.StringEntity#<init>(java.lang.String,java.lang.String) | ||
org.apache.http.entity.StringEntity#<init>(java.lang.String,java.nio.charset.Charset) | ||
org.apache.http.entity.ByteArrayEntity#<init>(byte[]) | ||
org.apache.http.entity.ByteArrayEntity#<init>(byte[],int,int) | ||
org.apache.http.entity.FileEntity#<init>(java.io.File) | ||
org.apache.http.entity.InputStreamEntity#<init>(java.io.InputStream) | ||
org.apache.http.entity.InputStreamEntity#<init>(java.io.InputStream,long) | ||
org.apache.http.nio.entity.NByteArrayEntity#<init>(byte[]) | ||
org.apache.http.nio.entity.NByteArrayEntity#<init>(byte[],int,int) | ||
org.apache.http.nio.entity.NFileEntity#<init>(java.io.File) | ||
org.apache.http.nio.entity.NStringEntity#<init>(java.lang.String) | ||
org.apache.http.nio.entity.NStringEntity#<init>(java.lang.String,java.lang.String) | ||
|
||
@defaultMessage Use non-deprecated constructors | ||
org.apache.http.nio.entity.NFileEntity#<init>(java.io.File,java.lang.String) | ||
org.apache.http.nio.entity.NFileEntity#<init>(java.io.File,java.lang.String,boolean) | ||
org.apache.http.entity.FileEntity#<init>(java.io.File,java.lang.String) | ||
org.apache.http.entity.StringEntity#<init>(java.lang.String,java.lang.String,java.lang.String) | ||
|
||
@defaultMessage BasicEntity is easy to mess up and forget to set content type | ||
org.apache.http.entity.BasicHttpEntity#<init>() | ||
|
||
@defaultMessage EntityTemplate is easy to mess up and forget to set content type | ||
org.apache.http.entity.EntityTemplate#<init>(org.apache.http.entity.ContentProducer) | ||
|
||
@defaultMessage SerializableEntity uses java serialization and makes it easy to forget to set content type | ||
org.apache.http.entity.SerializableEntity#<init>(java.io.Serializable) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
import org.apache.http.client.utils.URIBuilder; | ||
import org.apache.http.concurrent.FutureCallback; | ||
import org.apache.http.conn.ConnectTimeoutException; | ||
import org.apache.http.entity.ContentType; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.impl.auth.BasicScheme; | ||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; | ||
|
@@ -293,7 +294,7 @@ public void testIOExceptions() throws IOException { | |
*/ | ||
public void testBody() throws IOException { | ||
String body = "{ \"field\": \"value\" }"; | ||
StringEntity entity = new StringEntity(body); | ||
StringEntity entity = new StringEntity(body, ContentType.APPLICATION_JSON); | ||
for (String method : Arrays.asList("DELETE", "GET", "PATCH", "POST", "PUT")) { | ||
for (int okStatusCode : getOkStatusCodes()) { | ||
Response response = restClient.performRequest(method, "/" + okStatusCode, Collections.<String, String>emptyMap(), entity); | ||
|
@@ -431,7 +432,7 @@ private HttpUriRequest performRandomRequest(String method) throws Exception { | |
HttpEntity entity = null; | ||
boolean hasBody = request instanceof HttpEntityEnclosingRequest && getRandom().nextBoolean(); | ||
if (hasBody) { | ||
entity = new StringEntity(randomAsciiOfLengthBetween(10, 100)); | ||
entity = new StringEntity(randomAsciiOfLengthBetween(10, 100), ContentType.APPLICATION_JSON); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for fixing all these. |
||
((HttpEntityEnclosingRequest) request).setEntity(entity); | ||
} | ||
|
||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also add ByteArrayEntity here? what is the difference between the http-signatures file below and this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ I should add all of those here. The difference is the http-signatures file is used only for the rest projects as they do not use the es-test-signatures.
I could move the http signatures to the buildSrc and then have the default forbidden apis for tests include that file as well. This way we only need to update the file in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would do that, unless there are downsides that I am not seeing