Thanks, Ryan. Putting the xdmp:set-response-code after the redirect is indeed 
the solution.

From: [email protected] 
[mailto:[email protected]] On Behalf Of 
[email protected]
Sent: Tuesday, November 30, 2010 3:26 PM
To: [email protected]
Subject: Re: [MarkLogic Dev General] 302 redirect response

Stewart, this has worked for us. Called from a rewriter:

declare function local:redirect-from-old-url($new-url) {
    ("/", xdmp:redirect-response($new-url), xdmp:set-response-code(302, 
"Found"), xdmp:add-response-header("Location", $new-url))
};
________________________________
From: [email protected]
Date: Tue, 30 Nov 2010 21:56:55 +0000
To: [email protected]
Subject: Re: [MarkLogic Dev General] 302 redirect response

Hi Stewart,

I don't have a MarkLogic Server here handy but have you tried this in the 
browser or in a tool like curl? It might be that you are following the response 
and consequently getting a 200?

I remember doing some testing on this in MarkLogic API 
[https://github.com/dscape/MarkLogicAPI/blob/master/test/remove-later.sh] and 
from what I recall it did return 301 with appropriate headers. Then again it 
was some months ago.

Nuno

On Tue, Nov 30, 2010 at 9:09 PM, Stewart Shelline 
<[email protected]<mailto:[email protected]>> wrote:
Yeah, I tried that. Unfortunately, the following returns 200/OK instead of a 
302:

let $new-page := "redirectee.xqy"
return
    (xdmp:set-response-code( 302, "Moved permanently" ),
    xdmp:redirect-response( $new-page ))



From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Nuno Job
Sent: Tuesday, November 30, 2010 2:07 PM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] 302 redirect response

Try xdmp:set-response-code()

http://developer.marklogic.com/pubs/3.2/apidocs/AppServerBuiltins.html#set-response-code

Nuno
On Tue, Nov 30, 2010 at 8:56 PM, Stewart Shelline 
<[email protected]<mailto:[email protected]>> wrote:
Is there any way to use xdmp:redirect-response() to send a response code of 
302? Or is there a better way to do this?


NOTICE: This email message is for the sole use of the intended recipient(s) and 
may contain confidential and privileged information. Any unauthorized review, 
use, disclosure or distribution is prohibited. If you are not the intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.


_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________ General mailing list 
[email protected] 
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to