1 18 19 package org.apache.jmeter.protocol.http.sampler; 20 21 import java.net.URL ; 22 23 import org.apache.jmeter.samplers.SampleResult; 24 25 31 public class HTTPSampleResult extends SampleResult 32 { 33 public HTTPSampleResult() 34 { 35 super(); 36 } 37 38 public HTTPSampleResult(long elapsed) 39 { 40 super(elapsed,true); 41 } 42 43 49 public HTTPSampleResult(HTTPSampleResult res) 50 { 51 super(res); 52 53 setHTTPMethod(res.getHTTPMethod()); 54 setURL(res.getURL()); 55 setCookies(res.getCookies()); 56 } 57 58 private String method; 59 60 public void setHTTPMethod(String method) { 61 this.method= method; 62 } 63 public String getHTTPMethod() { 64 return method; 65 } 66 67 private String redirectLocation; 68 69 public void setRedirectLocation(String redirectLocation) 70 { 71 this.redirectLocation= redirectLocation; 72 } 73 public String getRedirectLocation() 74 { 75 return redirectLocation; 76 } 77 78 83 public boolean isRedirect() 84 { 85 final String [] REDIRECT_CODES= { "301", "302", "303" }; String code= getResponseCode(); 87 for (int i= 0; i < REDIRECT_CODES.length; i++) 88 { 89 if (REDIRECT_CODES[i].equals(code)) 90 return true; 91 } 92 return false; 93 } 94 95 96 99 public String getSamplerData() 100 { 101 StringBuffer sb= new StringBuffer (); 102 sb.append(getHTTPMethod()); 103 URL u= super.getURL(); 104 if (u != null) 105 { 106 sb.append(' '); 107 sb.append(u.toString()); 108 } 109 String s= super.getSamplerData(); 110 if (s != null) 111 { 112 sb.append('\n'); 113 sb.append(s); 114 } 115 return sb.toString(); 116 } 117 118 private String cookies=""; 122 public String getCookies() 123 { 124 return cookies; 125 } 126 127 130 public void setCookies(String string) 131 { 132 cookies = string; 133 } 134 135 private String queryString = ""; 141 public String getQueryString() 142 { 143 return queryString; 144 } 145 146 151 public void setQueryString(String string) 152 { 153 queryString = string; 154 } 155 156 } 157 | Popular Tags |