cancel
Showing results for 
Search instead for 
Did you mean: 

Random HTTP 400 error on POST request to alfresco

ulxdanny
Champ in-the-making
Champ in-the-making
I got a problem with getting POST HTTP request in alfresco.


I send a request with YAHOO.asyncRequest to /share/proxy/alfresco/… and sometimes i got a 400 response code.
I always send the same request, and same parameters, so the problem is not here.
I debugged Alfresco's code, and i realesed that RemoteClient send the HTTP request to /alfresco/s/…?ALF_TICEKT=…, but if error occours i can't see the request on alfresco side. On response 400 recieved.

I tcpdumpped the request and if everything is alright i can see this:

<blockcode>
POST /alfresco/s/…/institution-registration?close=true&instID=2&alf_ticket=TICKET_1eb2ac478ba6b2389c831de9014d3ab4564e4855 HTTP/1.1
connection: keep-alive
content-length: 0
origin: http://dani-alf:8080
x-requested-with: application/json
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
accept: */*
referer: http://dani-alf:8080/share/page/user/.../dashboard
accept-encoding: gzip,deflate,sdch
accept-language: hu-HU,hu;q=0.8,en-US;q=0.6,en;q=0.4
Content-Type: application/json
Host: localhost:8080
Expect: 100-continue


HTTP/1.1 100 Continue


HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Length: 133
Date: Thu, 03 Jul 2014 07:40:19 GMT



HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Thu, 03 Jul 2014 07:40:19 GMT
Connection: close


</blockcode>

If HTTP 400 occours:


POST /alfresco/s/…/institution-registration?close=true&instID=2&alf_ticket=TICKET_1eb2ac478ba6b2389c831de9014d3ab4564e4855 HTTP/1.1
connection: keep-alive
content-length: 0
origin: http://dani-alf:8080
x-requested-with: application/json
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
accept: */*
referer: http://dani-alf:8080/share/page/user/.../dashboard
accept-encoding: gzip,deflate,sdch
accept-language: hu-HU,hu;q=0.8,en-US;q=0.6,en;q=0.4
Content-Type: application/json
Host: localhost:8080
Expect: 100-continue


In the logs:



DEBUG [webscripts.connector.HttpConnector] [http-bio-8080-exec-218] Requested Method: POST URI: /…/institution-registration?close=true&instID=2
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218] Executing (POST) http://localhost:8080/alfresco/s/.../institution-registration?close=true&instID=2&alf_ticket=TICKET_...
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218]  - InputStream supplied - will push…
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218]  - OutputStream supplied - will stream response…
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218]  - OutputStream supplied - will stream response…
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218]  - Full Proxy mode between servlet request and response…
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218] Creating HttpClient instance for thread: http-bio-8080-exec-218
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218] Set Content-Type=application/json
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218] POST entity Content-Length=-2
… MY CODE …
org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218] Response status code: 200
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-218] Response encoding: null
DEBUG [webscripts.connector.AuthenticatingConnector] [http-bio-8080-exec-218] Received 200 on first call to: /…/institution-registration?close=true&instID=2
DEBUG [servlet.mvc.EndPointProxyController] [http-bio-8080-exec-218] Return code: 200



Bad request log:


DEBUG [webscripts.connector.HttpConnector] [http-bio-8080-exec-112] Requested Method: POST URI: /…/institution-registration?close=true&instID=2
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-112] Executing (POST) http://localhost:8080/alfresco/s/.../institution-registration?close=true&instID=2&alf_ticket=TICKET_...
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-112]  - InputStream supplied - will push…
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-112]  - OutputStream supplied - will stream response…
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-112]  - Full Proxy mode between servlet request and response…
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-112] Set Content-Type=application/json
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-112] POST entity Content-Length=-2
DEBUG [webscripts.connector.RemoteClient] [http-bio-8080-exec-112] Response status code: 400
DEBUG [webscripts.connector.AuthenticatingConnector] [http-bio-8080-exec-112] Received 400 on first call to: /…/institution-registration?close=true&instID=2
DEBUG [servlet.mvc.EndPointProxyController] [http-bio-8080-exec-112] Return code: 400



i figured out that on GET requests it doesn't happen.
Any suggestion?
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

please be aware that you need to handle the CSRF token manually when not using the Alfresco.util.Ajax utility, otherwise Share may reject a request due to missing / unmatching CSRF token in request. Please see <a href="http://blogs.alfresco.com/wp/ewinlof/2013/03/11/introducing-the-new-csrf-filter-in-alfresco-share/">Introducing the new CSRF filter in Alfresco</a> for details. Also note a special issue that affects POST request in a tabbed browsing scenario: <a href="https://issues.alfresco.com/jira/browse/ALF-20815">ALF-20815</a>.


Regards
Axel

ulxdanny
Champ in-the-making
Champ in-the-making
Thank you for your answer, CSRF token handling was the problem.