cookies

Friday 17 March 2023

Wildfly 26 - dump http request/reponse with body

I've been messing around with WF26 at work lately.

Sadly good 'ol

  <system-properties>
    <property name="org.apache.cxf.logging.enabled" value="true"/>
    <property name="com.sun.xml.ws.transport.http.HttpAdapter.dump" value="true"/>
  </system-properties>

doesn't work anymore :(

Most i could find is posts about io.undertow.server.handlers.RequestDumpingHandler

Based on https://issues.redhat.com/browse/UNDERTOW-854

I got WF26 to dump Response + body.

In standalone.xml - in  section <subsystem xmlns="urn:jboss:domain:undertow:12.0"

  <server name="default-server">
..
      <host name="default-host" alias="localhost">
          <location name="/" handler="welcome-content"/>
..
          <filter-ref name="request-dumper"/>
          <filter-ref name="store-response"/>
      </host>
  </server>
  <servlet-container name="default">
..
  </handlers>
  <filters>
    <filter name="request-dumper" class-name="io.undertow.server.handlers.RequestDumpingHandler" module="io.undertow.core"/>
    <filter name="store-response" class-name="io.undertow.server.handlers.StoredResponseHandler" module="io.undertow.core"/>
  </filters>


Adding EagerFormParsingHandler gave me errors - so skip that. 

Ta-ducking-da

2023-03-17 09:30:52,700 INFO  [io.undertow.request.dump] (default task-1)
----------------------------REQUEST---------------------------
               URI=/server-example-rest/rest/test/
 characterEncoding=null
     contentLength=70
       contentType=[application/json;charset=UTF-8]
            header=Connection=Keep-Alive
            header=Accept=application/json;charset=UTF-8,application/xml;charset=UTF-8
            header=Authorization=Basic xxxxxxxxxxxx
            header=Content-Type=application/json;charset=UTF-8
            header=Content-Length=70
            header=User-Agent=Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)
            header=Host=10.20.30.40:8443
            locale=[]
            method=POST
          protocol=HTTP/1.1
       queryString=
        remoteAddr=test/10.20.30.41:55061
        remoteHost=test
            scheme=https
              host=10.20.30.40:8443
        serverPort=8443
          isSecure=true
--------------------------RESPONSE--------------------------
     contentLength=54
       contentType=application/json; charset=UTF-8
            header=Expires=0
            header=Connection=keep-alive
            header=Cache-Control=no-cache, no-store, must-revalidate
            header=Pragma=no-cache
            header=Content-Type=application/json; charset=UTF-8
            header=Content-Length=54
            header=Date=Fri, 17 Mar 2023 08:30:52 GMT
            status=200
body=
{"errors":[],"data":[{"something":"Test","example"}]}