Skip to content

DCOS Sub Command CLI has problems with POSTing multipart #818

@huntc

Description

@huntc

Please answer the following questions before submitting your issue. Thanks!

What version of DC/OS + DC/OS CLI are you using (dcos --version)?

dcoscli.version=0.4.10
dcos.version=1.8.4
dcos.commit=e64024af95b62c632c90b9063ed06296fcf38ea5
dcos.bootstrap-id=5b4aa43610c57ee1d60b4aa0751a1fb75824c083

What operating system and version are you using?

OS X 10.11.6

What did you do?

I'm writing a custom sub command and I'm using the DC/OS Python http library (0.4.14). When performing a POST request that uploads files I receive a bad request status back. The reason for this is because the DC/OS implementation of the post request makes several attempts. The first attempt is without authorisation, and the subsequent ones are with authorisation. Because I'm uploading a multipart file, and the stream associated with the request isn't reset, no content will be sent on the subsequent requests. Here's how I prepare the request:

        files.append(('bundle', (bundle_name, open(bundle_file, 'rb'))))

What did you expect to see?

That my load request succeed even on subsequent attempts.

What did you see instead?

The first load correctly streams the parts, but the subsequent ones do not. The first one fails though because authorisation is required.


The solution is for your flavour of the requests post method to scan through the files data structure and reset any stream found by calling seek(0).

Even better, why even retry? Why not just one request with authorisation always? I'd state that you've broken the contract of the request post method, and that perhaps this should be some higher level function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions