changeset 625:96cfb7cf66f3

extractors - support for req.url.*
author Devel 1
date Mon, 16 Oct 2017 16:41:25 +0200
parents d599f5455379
children 53957b94f932
files stress-tester/src/main/java/com/passus/st/filter/HttpMessageValueExtractor.java
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/filter/HttpMessageValueExtractor.java	Fri Oct 13 14:47:13 2017 +0200
+++ b/stress-tester/src/main/java/com/passus/st/filter/HttpMessageValueExtractor.java	Mon Oct 16 16:41:25 2017 +0200
@@ -1,6 +1,7 @@
 package com.passus.st.filter;
 
 import com.passus.filter.ValueExtractor;
+import com.passus.net.http.URL;
 import com.passus.st.client.http.filter.HttpMessageWrapper;
 import java.util.Objects;
 
@@ -56,6 +57,28 @@
             case "resp.getStatus().getCode()":
                 return wrapper.getResp().getStatus().getCode();
             default:
+                if (fieldName.startsWith("req.url.")) {
+                    URL url = wrapper.getReq().getUrl();
+                    String urlPart = fieldName.substring(8);
+                    switch (urlPart) {
+                        case "authority":
+                            return url.getAuthority();
+                        case "host":
+                            return url.getHost();
+                        case "path":
+                            return url.getPath();
+                        case "port":
+                            return url.getPort();
+                        case "query":
+                            return url.getQuery();
+                        case "ref":
+                            return url.getRef();
+                        case "scheme":
+                            return url.getScheme();
+                        case "userInfo":
+                            return url.getUserInfo();
+                    }
+                }
                 return fallbackExtractor.extract(wrapper);
         }
     }