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

Disable Expect100Continue and how to sub-class S3 Requests #3375

Open
ashishdhingra opened this issue Jul 5, 2024 Discussed in #3356 · 1 comment
Open

Disable Expect100Continue and how to sub-class S3 Requests #3375

ashishdhingra opened this issue Jul 5, 2024 Discussed in #3356 · 1 comment
Labels
bug This issue is a bug. p2 This is a standard priority issue queued s3

Comments

@ashishdhingra
Copy link
Contributor

Discussed in #3356

Originally posted by DetlefGolze June 26, 2024
I want to disable the Expect100Continue header and thought that it is as easy as creating a derived class of PutObjectRequest which already has an overridable property for this:

	public partial class MyPutObjectRequest : PutObjectRequest 
	{
		public MyPutObjectRequest()
		{
			// This is the default setting in base library
			//
			MyExpect100Continue = true;
		}

		public bool MyExpect100Continue { get; set; }

                protected override bool Expect100Continue
                {  get  { return MyExpect100Continue; }    }
	}

So far so good. This compiles and appears to do what I expect. However, the AmazonS3ControlEndpointResolver uses the name of the request class to implement some request specific behavior causing requests to fail which use an unknown type.

So, two questions:
Is there a better way to disable Expect100Continue? I suppose it is not used as intended anyway and only generates overhead.

Is there an official way to create sub-classes of Request classes? Except of the above example I was hoping that I can use this to pass data from and to an AfterResponseEvent. My S3Client is shared by many threads and this would make life much easier.
We could add a request property which returns the expected RequestName or just use something like this in AmazonS3ControlEndpointResolver:

    if (request is PutObjectRequest)
    {
    }
@ashishdhingra ashishdhingra added feature-request A feature should be added or improved. s3 p2 This is a standard priority issue labels Jul 5, 2024
@bhoradc bhoradc added the queued label Jul 8, 2024
@grenyg
Copy link

grenyg commented Jul 15, 2024

Hi, just want to add my findings if it helps someone.

Had the same problem as @DetlefGolze trying to disable Expect100Continue. Then I saw his findings about the class name causing issues. So I tried naming the derived class PutObjectRequest and it works!

public class PutObjectRequest : Amazon.S3.Model.PutObjectRequest { protected override bool Expect100Continue => false; }

Ps. My use case is that I'm calling a "compatible" non-AWS-S3 backend that doesn't support the Expect: 100-Continue header which causes a 1 sec delay. I'm using .NET 8.

@bhoradc bhoradc added bug This issue is a bug. and removed feature-request A feature should be added or improved. labels Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue queued s3
Projects
None yet
Development

No branches or pull requests

3 participants