[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit WebConversation.java,1.18,1.19 WebForm.ja
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2001-03-23 20:50:45
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv8865/src/com/meterware/httpunit
Modified Files:
WebConversation.java WebForm.java WebLink.java WebRequest.java
Log Message:
Added referer header support
Index: WebConversation.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebConversation.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WebConversation.java 2000/11/21 20:44:58 1.18
+++ WebConversation.java 2001/03/23 20:50:41 1.19
@@ -55,6 +55,7 @@
**/
protected WebResponse newResponse( WebRequest request ) throws MalformedURLException, IOException {
URLConnection connection = openConnection( request.getURL() );
+ sendHeaders( connection, request.getHeaders() );
request.completeRequest( connection );
return new HttpWebResponse( request.getTarget(), request.getURL(), connection );
}
@@ -76,11 +77,14 @@
private void sendHeaders( URLConnection connection ) {
- Dictionary headers = getHeaderFields();
+ sendHeaders( connection, getHeaderFields() );
+ }
+
+
+ private void sendHeaders( URLConnection connection, Dictionary headers ) {
for (Enumeration e = headers.keys(); e.hasMoreElements();) {
String key = (String) e.nextElement();
connection.setRequestProperty( key, (String) headers.get( key ) );
}
}
-
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WebForm.java 2001/02/21 19:01:07 1.19
+++ WebForm.java 2001/03/23 20:50:41 1.20
@@ -240,6 +240,7 @@
}
}
}
+ result.setRequestHeader( "Referer", _baseURL.toExternalForm() );
return result;
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebLink.java 2000/10/05 14:45:14 1.5
+++ WebLink.java 2001/03/23 20:50:41 1.6
@@ -20,7 +20,9 @@
* Creates and returns a web request which will simulate clicking on this link.
**/
public WebRequest getRequest() {
- return new GetMethodWebRequest( _baseURL, getURLString(), getTarget() );
+ WebRequest request = new GetMethodWebRequest( _baseURL, getURLString(), getTarget() );
+ request.setRequestHeader( "Referer", _baseURL.toExternalForm() );
+ return request;
}
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- WebRequest.java 2001/02/21 19:01:07 1.14
+++ WebRequest.java 2001/03/23 20:50:41 1.15
@@ -266,6 +266,16 @@
}
+ void setRequestHeader( String headerName, String headerValue ) {
+ _headers.put( headerName.toUpperCase(), headerValue );
+ }
+
+
+ Dictionary getHeaders() {
+ return _headers;
+ }
+
+
static class UploadFileSpec {
UploadFileSpec( File file ) {
_file = file;
@@ -311,6 +321,7 @@
private WebForm _sourceForm;
private String _imageButtonName;
private String _target = TOP_FRAME;
+ private Hashtable _headers = new Hashtable();
private boolean _httpsProtocolSupportEnabled;
|