2222public class HttpImpl {
2323 private static IastClassLoader iastClassLoader ;
2424 public static File IAST_REQUEST_JAR_PACKAGE ;
25+ public static final String HEADER_DAST_MARK = "dt-mark-header" ;
26+ public static final String HEADER_DAST = "dt-dast" ;
2527
2628 static {
2729 IAST_REQUEST_JAR_PACKAGE = new File (PropertyUtils .getTmpDir () + "dongtai-api.jar" );
@@ -83,8 +85,9 @@ public static void solveHttpRequest(Object obj, Object req, Object resp, Map<Str
8385 try {
8486 boolean enableVersionHeader = ((Config <Boolean >) ConfigBuilder .getInstance ()
8587 .getConfig (ConfigKey .ENABLE_VERSION_HEADER )).get ();
86- String xrayHeader = ((Map <String , String >) requestMeta .get ("headers" )).get ("dt-dast" );
87- if (enableVersionHeader || xrayHeader != null ) {
88+ String dastHeader = ((Map <String , String >) requestMeta .get ("headers" )).get (HEADER_DAST );
89+ String dastMarkHeader = ((Map <String , String >) requestMeta .get ("headers" )).get (HEADER_DAST_MARK );
90+ if (enableVersionHeader || dastHeader != null || dastMarkHeader != null ) {
8891 Method setHeaderMethod = ReflectUtils .getDeclaredMethodFromSuperClass (resp .getClass (),
8992 "setHeader" , new Class []{String .class , String .class });
9093 if (setHeaderMethod != null ) {
@@ -93,12 +96,15 @@ public static void solveHttpRequest(Object obj, Object req, Object resp, Map<Str
9396 .getConfig (ConfigKey .VERSION_HEADER_KEY )).get ();
9497 setHeaderMethod .invoke (resp , versionHeaderKey , AgentConstant .VERSION_VALUE );
9598 }
96- if (xrayHeader != null ) {
99+ if (dastMarkHeader != null ) {
97100 String reqId = String .valueOf (EngineManager .getAgentId ()) + "."
98101 + UUID .randomUUID ().toString ().replaceAll ("-" , "" );
99102 setHeaderMethod .invoke (resp , "dt-request-id" , reqId );
100103 }
101104 }
105+ if (dastHeader != null ) {
106+ return ;
107+ }
102108 }
103109 } catch (Throwable ignore ) {
104110 }
@@ -149,8 +155,10 @@ public static Map<String, String> parseRequestHeaders(Object req, Enumeration<?>
149155 String val = (String ) getHeaderMethod .invoke (req , key );
150156 if ("content-type" .equalsIgnoreCase (key )) {
151157 key = "Content-Type" ;
152- } else if ("dt-dast" .equalsIgnoreCase (key )) {
153- key = "dt-dast" ;
158+ } else if (HEADER_DAST_MARK .equalsIgnoreCase (key )) {
159+ key = HEADER_DAST_MARK ;
160+ } else if (HEADER_DAST .equalsIgnoreCase (key )) {
161+ key = HEADER_DAST ;
154162 }
155163 headers .put (key , val );
156164 } catch (Throwable ignore ) {
0 commit comments