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

Object Storage copy method - Content-Length header already present #872

Closed
lilloxxx opened this issue Oct 28, 2016 · 6 comments
Closed

Object Storage copy method - Content-Length header already present #872

lilloxxx opened this issue Oct 28, 2016 · 6 comments

Comments

@lilloxxx
Copy link

Hi,
I encountered an issue with this 'copy' method:

os.objectStorage().objects().copy(ObjectLocation.create(srcContainer, srcObject),
                ObjectLocation.create(destContainer, destObject));

I received this error:

Exception in thread "main" ConnectionException{status=0} at org.openstack4j.connectors.resteasy.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:56) at org.openstack4j.connectors.resteasy.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:30) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.executeWithResponse(BaseOpenStackService.java:197) at org.openstack4j.openstack.storage.object.internal.ObjectStorageObjectServiceImpl.copy(ObjectStorageObjectServiceImpl.java:173) at inebula.openstack.identity.test(identity.java:240) at inebula.openstack.identity.main(identity.java:282) Caused by: org.apache.http.client.ClientProtocolException at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:822) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754) at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.execute(ApacheHttpClient4Executor.java:182) at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:438) at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:688) at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:694) at org.openstack4j.connectors.resteasy.HttpCommand.execute(HttpCommand.java:65) at org.openstack4j.connectors.resteasy.HttpExecutorServiceImpl.invokeRequest(HttpExecutorServiceImpl.java:61) at org.openstack4j.connectors.resteasy.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:54) ... 6 more Caused by: org.apache.http.ProtocolException: **Content-Length header already present** at org.apache.http.protocol.RequestContent.process(RequestContent.java:67) at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:108) at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:174) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:462) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)

Version:

<dependency> <groupId>org.pacesys</groupId> <artifactId>openstack4j</artifactId> <version>3.0.2</version> </dependency>

Please let me know how I can provide more details.
Regards,
lilloxxx

@auhlig
Copy link
Member

auhlig commented Oct 28, 2016

Content-Length header already present? Worth to turn on debug logging to see the request by OSFactory.enableHttpLoggingFilter(true);

@lilloxxx
Copy link
Author

lilloxxx commented Nov 2, 2016

Hi Arno,
thanks for your fast reply.

I noticed that i'm already using the option 'OSFactory.enableHttpLoggingFilter(true);' yet .
But I obtain the debug of HTTP's calls on console only with previous version of openstack4j.

So using:

<artifactId>openstack4j</artifactId>
<version>3.0.0</version>

With this version the error message is different, now it's 'Missing Content-Length header.', as reported:

nov 02, 2016 9:52:15 AM org.glassfish.jersey.client.JerseyInvocation validateHttpMethodAndEntity
AVVERTENZA: Entity must not be null for http method PUT.
nov 02, 2016 9:52:15 AM org.glassfish.jersey.filter.LoggingFilter log
INFORMAZIONI: 1 * Sending client request on thread main
1 > PUT https://<servername>.it/v1/AUTH_e64d1ed81f00418884df4330c25d3199/Container_pseudo_dir/respin_conf.tar.gz_CopiedObject
1 > Accept: application/json
1 > Content-Length: 0
1 > X-Auth-Token: gAAAAABYGcVwgjs1EmctTC02EPmdT9fRlCSEstxIYq0HvxUP3ue6hedOaobrsAVpkDaoWzBAvJ4hrNlrODAtBe2GFeMW5PRD5fNuKeGqFbbV86bzLT7tOx6EVDzDaWsfxgBWdcw6kXM3XqzU19GW2PUjSoSghJCDSvKkQvuMjWPcs0UHvQ38k3Q
1 > X-Copy-From: /Container_pseudo_dir/respin_conf.tar.gz

nov 02, 2016 9:52:15 AM org.glassfish.jersey.client.internal.HttpUrlConnector setOutboundHeaders
AVVERTENZA: Attempt to send restricted header(s) while the [sun.net.http.allowRestrictedHeaders] system property not set. Header(s) will possibly be ignored.
nov 02, 2016 9:52:15 AM org.glassfish.jersey.filter.LoggingFilter log
INFORMAZIONI: 1 * Client response received on thread main
1 < 411
1 < Connection: close
1 < Content-Length: 30
1 < Content-Type: text/plain
1 < Date: Wed, 02 Nov 2016 10:52:35 GMT
1 < Server: Apache/2.4.18 (Ubuntu)
1 < X-Trans-Id: tx69d713746ea642589d5e9-005819c572
Missing Content-Length header.

Thanks in advice for any help.
Regards,
lilloxxx

@auhlig
Copy link
Member

auhlig commented Nov 2, 2016

Compared to the API http://developer.openstack.org/api-ref/object-storage/?expanded=copy-object-detail#copy-object the request looks good, doesn't it?

Does this work via swift- or openstack client?

@lilloxxx
Copy link
Author

lilloxxx commented Nov 4, 2016

Hi Arno,
you are right, the request looks good reading the log but could be not as seems.
Please, follow me in the example.

This the request, reading log:

PUT
https://<servername>.it/v1/AUTH_e64d1ed81f00418884df4330c25d3199/Container_pseudo_dir/respin_conf.tar.gz_CopiedObject
Accept: application/json
Content-Length: 0
X-Auth-Token: gAAAAABYGcVwgjs1EmctTC02EPmdT9fRlCSEstxIYq0HvxUP3ue6hedOaobrsAVpkDaoWzBAvJ4hrNlrODAtBe2GFeMW5PRD5fNuKeGqFbbV86bzLT7tOx6EVDzDaWsfxgBWdcw6kXM3XqzU19GW2PUjSoSghJCDSvKkQvuMjWPcs0UHvQ38k3Q
X-Copy-From: /Container_pseudo_dir/respin_conf.tar.gz

and this is the response, from log:

411
Connection: close
Content-Length: 30
Content-Type: text/plain
Date: Wed, 02 Nov 2016 10:52:35 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Trans-Id: tx69d713746ea642589d5e9-005819c572
Missing Content-Length header.

If the request were correct the response should be different, somethings like HTTP/1.1 201 Created.
So, I think something it went wrong.

I tried to replicate the error HTTP/1.1 411 Length Required that I receive from server.
Based on my simulation the request sent is different from the request logged.

This is what happening:

Logged Request('Content-Length: 0' is ok):

PUT https://<servername>.it/v1/AUTH_e64d1ed81f00418884df4330c25d3199/Container_pseudo_dir/respin_conf.tar.gz_CopiedObject
 Accept: application/json
 Content-Length: 0
 X-Auth-Token: gAAAAABYGcVwgjs1EmctTC02EPmdT9fRlCSEstxIYq0HvxUP3ue6hedOaobrsAVpkDaoWzBAvJ4hrNlrODAtBe2GFeMW5PRD5fNuKeGqFbbV86bzLT7tOx6EVDzDaWsfxgBWdcw6kXM3XqzU19GW2PUjSoSghJCDSvKkQvuMjWPcs0UHvQ38k3Q
 X-Copy-From: /Container_pseudo_dir/respin_conf.tar.gz

Actual Request('Content-Length: 0' is missing):

PUT   /v1/AUTH_e64d1ed81f00418884df4330c25d3199/Container_pseudo_dir/respin_conf.tar.gz_CopiedObject HTTP/1.1
Accept: application/json
X-Auth-Token: gAAAAABYHKRTLQJ4pI5JPUuhnMWYmelfdXq6PoLivkD1X6Z206zgCViwYGrlxwPt1OmihKM5S4RXbCx7SlPVyX-rEs72VSH-wd0RZUZ-zB3M7olAlvE4MyUMqTjx4mAtz5joUrf2M8NTIsbpajmXL1YqnMuWOlUDqLpZNZsJH2OOZ6NUreY0wno
X-Copy-From: /Container_pseudo_dir/respin_conf.tar.gz
User-Agent: Jersey/2.22.1 (HttpUrlConnection 1.8.0_102)
Host: swiftproxyt.inebula.it
Connection: close


Logged Response:

411
Connection: close
Content-Length: 30
Content-Type: text/plain
Date: Wed, 02 Nov 2016 10:52:35 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Trans-Id: tx69d713746ea642589d5e9-005819c572
Missing Content-Length header.

Actual Response:

HTTP/1.1 411 Length Required
Date: Fri, 04 Nov 2016 15:10:18 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 30
Content-Type: text/plain
X-Trans-Id: tx95dafeb506a244aca5b4e-00581ca4da
Connection: close

Missing Content-Length header. 

In this case there is a match between simulated and actual environment.

Looks around I found some reference about an issue (according someone) or feature (according others) about the use of "Content-Length" by Jersey and Apache Connector.
I don't know well this libs.

May be something related to this issue:
square/retrofit#454

Thanks for any tips,
lilloxxx

###updated

If I use the following request all goes fine:

Request:

PUT /v1/AUTH_e64d1ed81f00418884df4330c25d3199/Container_pseudo_dir/respin_conf.tar.gz_CopiedObject HTTP/1.1
Accept: application/json
X-Auth-Token: gAAAAABYHKRTLQJ4pI5JPUuhnMWYmelfdXq6PoLivkD1X6Z206zgCViwYGrlxwPt1OmihKM5S4RXbCx7SlPVyX-rEs72VSH-wd0RZUZ-zB3M7olAlvE4MyUMqTjx4mAtz5joUrf2M8NTIsbpajmXL1YqnMuWOlUDqLpZNZsJH2OOZ6NUreY0wno
X-Copy-From: /Container_pseudo_dir/respin_conf.tar.gz
User-Agent: Jersey/2.22.1 (HttpUrlConnection 1.8.0_102)
Host: swiftproxyt.inebula.it
Connection: close
Content-Length: 0

Response:

HTTP/1.1 201 Created
Date: Fri, 04 Nov 2016 15:10:11 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 0
X-Copied-From-Last-Modified: Fri, 04 Nov 2016 11:26:50 GMT
X-Copied-From: Container_pseudo_dir/respin_conf.tar.gz
Last-Modified: Fri, 04 Nov 2016 15:10:12 GMT
Etag: c61ead50bef03305fa239e10db5f620e
X-Copied-From-Account: AUTH_e64d1ed81f00418884df4330c25d3199
Content-Type: text/html; charset=UTF-8
X-Trans-Id: tx86737f90df7d4d0c9cf28-00581ca4d3
Connection: close

@auhlig
Copy link
Member

auhlig commented Nov 4, 2016

Summing up: Content-Length header missing in the actual request using Jersey and Apache connector. Right?
Short-term you could try okhttp.

@lilloxxx
Copy link
Author

lilloxxx commented Nov 4, 2016

Thanks for the tip, it's working now!

Only for the records:
I modified my pom in this way, to force okhttp usage:

<dependencies>
    <!--    <dependency>
            <groupId>org.pacesys</groupId>
            <artifactId>openstack4j</artifactId>
            <version>3.0.2</version>
        </dependency> -->
                <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.21</version>
        </dependency>
          <dependency> <!-- okhttp -->
            <groupId>org.pacesys.openstack4j.connectors</groupId>
            <artifactId>openstack4j-okhttp</artifactId>
            <version>3.0.2</version>
        </dependency>
</dependencies>

Regards,
lilloxxx

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

No branches or pull requests

2 participants