translation in dpml

Poster Content
nk4um User
Posts: 49
March 2, 2012 16:52translation in dpml

Hi Tony,

Thanks. I got now what I needed. The linked Data 303 pattern.

<modify-responseassignment="response">
  <operand>this:response&lt;/operand&gt;
  <config>
    <literaltype="xml">
      <config>
        <headername="httpResponse:/code">303&lt;/header&gt;
        <headername="httpResponse:/header/Location">http://www.proxml.be/&lt;/header&gt;
      &lt;/config&gt;
    &lt;/literal&gt;
  &lt;/config&gt;
&lt;/modify-response&gt;
Like · Post Reply
nk4um Administrator
Posts: 607
March 2, 2012 16:00

Hi Paul,

firstly to directly translate these snippets you can use the SINK verb in DPML:

<request>
  <verb>SINK&lt;/verb&gt;
  <identifier>httpResponse:/code&lt;/identifier&gt;
  <argumentname="primary">
    <literaltype="integer">204&lt;/literal&gt;
  &lt;/argument&gt;
&lt;/request&gt;

However, like you are trying, you can set response headers to achieve the same effect and this is better for cachability as SINKing to http headers effectively inhibits caching due the side effect. So in DPML the modify-response tag can be used to add response headers:

<sequence>
  <literalassignment="response" type="string">hello world&lt;/literal&gt;
  <modify-responseassignment="response">
    <operand>this:response&lt;/operand&gt;
    <config>
      <literaltype="xml">
        <config>
          <headername="httpResponse:/code">204&lt;/header&gt;
        &lt;/config&gt;
      &lt;/literal&gt;
    &lt;/config&gt;
  &lt;/modify-response&gt;
&lt;/sequence&gt;

Cheers, Tony

Like · Post Reply
nk4um User
Posts: 49
March 1, 2012 11:05translation in dpml

I'm currently looking at following code snippets from the manual that I want to translate into dpml syntax.

httpResponse:/code

A request with the SINK verb sets the HTTP response code for the HTTP external response sent by the transport.

For example, to set the response code to "204":

public void onSource(INKFRequestContext context)

 {
 ...
 context.createResponseFrom(representation);
 ...
 context.sink("httpResponse:/code", 204);
 }

httpResponse:/redirect

A request with the SINK verb sets the HTTP code to "302" (redirect) and includes the new resource identifier.

For example, the following code will cause a redirect to be returned by the transport that will redirect the user to the 1060 Research web site:

public void onSource(INKFRequestContext context)

 {
 context.sink("httpResponse:/redirect", "http://www.1060research.com");
 }

I have been trying different things with modify-response

<modify-response>
	<operand>this:response</operand>
		<config>
			<literal type="xml">
				<config>
					???
				</config>
			</literal>
		</config>
				</modify-response>
but with no success.

Any additional input?

Like · Post Reply