Hi Chris,

Does the response contain a Content-Length? If not, maybe MarkLogic waits the 
full timeout before it decides there is none. If it has one (with a value of 
zero), that might be a bug..

Kind regards,
Geert

From: Chris Hudson-Silver 
<chris.hudson-sil...@ixxus.com<mailto:chris.hudson-sil...@ixxus.com>>
Reply-To: MarkLogic Developer Discussion 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Date: Thursday, January 8, 2015 at 11:12 AM
To: "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Subject: [MarkLogic Dev General] XDMP:http-get and 304 responses

Hi All,

Recently I was working on a project that tracks a repository by calling a REST 
webservice that returns back metadata and download URLS for items that have 
changed in the remote repository since the last call. It then checks to see if 
the item has already been downloaded and if so will call the download URL with 
the HTTP cache headers set as the modification could have been just metadata 
not content. E.g:

let $options := <options xmlns="xdmp:http"><headers><If-Modified-Since>Fri, 21 
Nov 2014 16:53:12 
GMT</If-Modified-Since><If-None-Match>"1416588792000"</If-None-Match></headers><repair
 xmlns="xdmp:document-get">full</repair></options>
let $response := xdmp:http-get($url, $options)

I noticed that the run time for this was considerably longer if some of the 
items would return back a Not Modified 304 response so decided to test if it 
was the remote repository or MarkLogic adding the overhead. I did this by 
creating a script that generated CURL commands so I could do the exact same 
requests from the command line and MarkLogic.
The calls back to the command line and Marklogic were returning the exact same 
response including the correct 304 code and an empty response body.
The calls from the command line were taking about 20 seconds less time than the 
calls from MarkLogic and seeing how the global timeout was set to 20 seconds I 
decided to try the MarkLogic calls but with a 1 second time out e.g:


let $options := <options 
xmlns="xdmp:http"><timeout>1</timeout><headers><If-Modified-Since>Fri, 21 Nov 
2014 16:53:12 
GMT</If-Modified-Since><If-None-Match>"1416588792000"</If-None-Match></headers><repair
 xmlns="xdmp:document-get">full</repair></options>

and now they are taking approximately 1 second longer than the calls from the 
command line.

Has anyone else encountered this?
Could it be that MarkLogic is waiting for the response body even though it has 
received a valid response header? The HTTP 1.1 standard states that a response 
does not necessarily need a response body so if this is the case it maybe a bug 
in MarkLogics HTTP module.
Or am I missing something vital in my request options?

Thanks in advance,

Chris

_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to