Forum Discussion

David_T's avatar
David_T
Icon for Nimbostratus rankNimbostratus
5 years ago

Modify XML POST request

Hi,

 

I need to change some values in an XML Post REQUEST to Sharepoint (search) as it embeds URL in the XML with https: and I need it to be http.

 

I was looking to use STREAM::EXPRESSION which I am successfully using for doing a similar replacement in the RESPONSE.

 

This is what I thought would work:

 

when HTTP_REQUEST {

  # Explicitly disable the stream profile for each client-side request so it doesn't stay

  #  enabled for subsequent HTTP requests on the same TCP connection.

  STREAM::disable

 

# The line below prevents the server from compressing its responses.

  HTTP::header remove "Accept-Encoding"

  # Apply stream profile against text responses from the application

if { [HTTP::method] eq "POST" } {

HTTP::collect

  set ispost 1

}

}

 

when HTTP_REQUEST_DATA {

  if { [HTTP::header value Content-Type] contains "text"} {

#replace https with http

STREAM::expression "@https://@http://@"

# enable the stream filter for this request only

STREAM::enable

}

//recalculate the content-length after the replacement

if { [info exists ispost] } {

HTTP::header insert Content-Length [HTTP::payload length]

}

}

 

But I am getting an HTTP 411 response from the backend (which I had thought recalculating the content-length header would fix).

 

Any pointers would be appreciated.

 

Regards,

David.

2 Replies

No RepliesBe the first to reply