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

Validate length of flux content matches with Content-Length header #4193

Closed
anuchandy opened this issue Jun 29, 2019 · 3 comments
Closed

Validate length of flux content matches with Content-Length header #4193

anuchandy opened this issue Jun 29, 2019 · 3 comments
Assignees
Labels
Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)

Comments

@anuchandy
Copy link
Member

Is your feature request related to a problem? Please describe.
Storage SDK has blob upload methods where user can provide flux emitting the content and length. The length become Content-Length header. A validation is missing that ensure length of data emitted by flux is equal to length param.

Describe the solution you'd like
instead of passing the flux to reactor-netty directly, append operators that does this check and pass updated flux to reactor-netty.

Describe alternatives you've considered
Adding this validation in storage SDK side is possible but with lot of code duplication since we have multiple upload methods.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [ X] Description Added
  • [X ] Expected solution specified
@anuchandy anuchandy added the Client This issue points to a problem in the data-plane of the library. label Jun 29, 2019
@anuchandy
Copy link
Member Author

anuchandy commented Jun 29, 2019

When this validation fails throw UnexpectedLengthException

/**
 * Indicates that a stream emitted an unexpected number of bytes.
 */
public class UnexpectedLengthException extends IllegalStateException {
    private final long bytesRead;
    private final long bytesExpected;

    /**
     * Creates an UnexpectedLengthException.
     * @param message the message
     * @param bytesRead the number of bytes actually read in the stream
     * @param bytesExpected the number of bytes expected to be read in the stream
     */
    public UnexpectedLengthException(String message, long bytesRead, long bytesExpected) {
        super(message);
        this.bytesRead = bytesRead;
        this.bytesExpected = bytesExpected;
    }

    /**
     * @return the number of bytes actually read in the stream
     */
    public long bytesRead() {
        return bytesRead;
    }

    /**
     * @return the number of bytes expected to be read in the stream
     */
    public long bytesExpected() {
        return bytesExpected;
    }
}

@jianghaolu
Copy link
Contributor

@joshfree this will unblock many Storage tests.

@sima-zhu
Copy link
Contributor

Verified the current structure.
RestProxy is the front door in azure core which can take in the request body.
Will add the validation in RestProxy.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

5 participants