Skip to content
Browse files

improve webdav plugin (TSUN-61). Works with litmus.

SVN Revision: 826
  • Loading branch information...
1 parent f90c348 commit 1fe17e033f2b6f0ad0732137053c553aaf6167fd @nniclausse nniclausse committed Apr 1, 2008
View
1 include/ts_http.hrl
@@ -92,6 +92,7 @@
-define(PUT, "PUT").
-define(HEAD, "HEAD").
-define(DELETE, "DELETE").
+-define(OPTIONS, "OPTIONS").
-define(USER_AGENT, "Tsung").
-define(USER_AGENT_ERROR_MSG, "Total sum of user agents frequency is not equal to 100").
View
3 src/tsung/ts_http.erl
@@ -73,6 +73,9 @@ get_message(Req=#http_request{method=delete}) ->
get_message(Req=#http_request{method=post}) ->
ts_http_common:http_body(?POST, Req);
+get_message(Req=#http_request{method=options}) ->
+ ts_http_common:http_no_body(?OPTIONS, Req);
+
get_message(Req=#http_request{method=put}) ->
ts_http_common:http_body(?PUT, Req).
View
7 src/tsung/ts_http_common.erl
@@ -500,9 +500,12 @@ http_method("copy")-> 'COPY';
http_method("move")-> 'MOVE';
http_method("lock")-> 'LOCK';
http_method("unlock")-> 'UNLOCK';
-http_method("mkdcol")-> 'MKCOL';
+http_method("mkcol")-> 'MKCOL';
http_method("report")-> 'REPORT';
-http_method(_) -> not_implemented.
+http_method("options")-> 'OPTIONS';
+http_method(Method) ->
+ ?LOGF("Unknown HTTP method: ~p~n", [Method] ,?WARN),
+ not_implemented.
%%--------------------------------------------------------------------
%% Func: parse_status/2
View
7 src/tsung/ts_utils.erl
@@ -407,8 +407,7 @@ to_https({request, String}) when is_list(String) ->
{ok,TmpString,Count} = regexp:gsub(String,"http://ssl-","https://"),
{ok,Tmp2,_} = regexp:gsub(TmpString,"Accept-Encoding: [0-9,a-zA-Z_]+\r\n",""),
{ok,RealString,_} = regexp:gsub(Tmp2,"Host: ssl-","Host: "),
- update_content_length(RealString,-Count);
-to_https(_) -> {error, bad_input}.
+ update_content_length(RealString,-Count).
from_https(String) when is_list(String)->
%% if location is defined, don't count it (not included in Content-Length)
@@ -423,12 +422,12 @@ from_https(String) when is_list(String)->
{Count,Location}->
?LOGF("substitute https: ~p times~n",[Count],?INFO),
update_content_length(NewString,Count+Location)
- end;
-from_https(_) -> {error, bad_input}.
+ end.
%% @spec update_content_length(String) -> {ok, String}
%% @doc since the length of URL is changed (https:// to http://ssl- )
%% we must recalculate Content-Length if it is defined.
+update_content_length(String,0) -> {ok, String } ;
update_content_length(String,Count) ->
case gregexp:groups(String,"[cC]ontent-[Ll]ength: \\([0-9]+\\)") of
{match,[CType]} ->
View
2 src/tsung_recorder/ts_client_proxy.erl
@@ -206,7 +206,7 @@ peername(Socket) -> prim_inet:peername(Socket).
send(_,[],_) -> ok; % no data
send({sslsocket,A,B},String, Plugin) ->
- ?LOGF("Received data to send to an ssl socket ~p~n", [String],?DEB),
+ ?LOGF("Received data to send to an ssl socket ~p, using plugin ~p ~n", [String,Plugin],?DEB),
{ok, RealString } = Plugin:rewrite_ssl({request,String}),
?LOGF("Sending data to ssl socket ~p ~p (~p)~n", [A, B, RealString],?DEB),
ssl:send({sslsocket,A,B}, RealString);
View
2 src/tsung_recorder/ts_proxy_http.erl
@@ -164,7 +164,7 @@ relative_url(true,String,_RequestURI,_RelURL)->
relative_url(false,String,RequestURI,RelURL)->
[FullURL_noargs|_] = string:tokens(RequestURI,"?"),
[RelURL_noargs|_] = string:tokens(RelURL,"?"),
- {ok,RealString,_Count} = regexp:gsub(String,FullURL_noargs,RelURL_noargs),
+ {ok,RealString,_Count} = regexp:sub(String,FullURL_noargs,RelURL_noargs),
{ok, RealString}.
%%--------------------------------------------------------------------
View
13 src/tsung_recorder/ts_proxy_webdav.erl
@@ -47,12 +47,14 @@ gettype() -> "ts_webdav".
%%--------------------------------------------------------------------
%% Func: rewrite_serverdata/1
%%--------------------------------------------------------------------
-rewrite_serverdata(Data)-> ts_proxy_http:rewrite_serverdata(Data).
+rewrite_serverdata(Data)->
+ ts_utils:from_https(Data).
%%--------------------------------------------------------------------
%% Func: rewrite_ssl/1
%%--------------------------------------------------------------------
-rewrite_ssl(Data)-> ts_proxy_http:rewrite_ssl(Data).
+rewrite_ssl(Data)->
+ ts_utils:to_https(Data).
%%--------------------------------------------------------------------
%% Func: parse/4
@@ -99,17 +101,18 @@ record_request(State=#state_rec{prev_host=Host, prev_port=Port, prev_scheme=Sche
io:format(Fd,"method='~s'>", [Method]),
+ %% authentication
+ ts_proxy_http:record_header(Fd,ParsedHeader,"authorization",
+ "~n <www_authenticate userid=~p passwd=~p />"),
%% webdav
ts_proxy_http:record_header(Fd,ParsedHeader,"depth", "~n <http_header name='depth' value='~s'/>~n"),
ts_proxy_http:record_header(Fd,ParsedHeader,"if", "~n <http_header name='if' value='~s'/>~n"),
ts_proxy_http:record_header(Fd,ParsedHeader,"timeout", "~n <http_header name='timeout' value='~s'/>~n"),
ts_proxy_http:record_header(Fd,ParsedHeader,"overwrite", "~n <http_header name='overwrite' value='~s'/>~n"),
+ ts_proxy_http:record_header(Fd,ParsedHeader,"destination", "~n <http_header name='destination' value='~s'/>~n", fun(A) -> ts_utils:to_https({url, A}) end),
ts_proxy_http:record_header(Fd,ParsedHeader,"url", "~n <http_header name='url' value='~s'/>~n"),
ts_proxy_http:record_header(Fd,ParsedHeader,"lock-tocken", "~n <http_header name='lock-tocken' value='~s'/>~n"),
- %% authentication
- ts_proxy_http:record_header(Fd,ParsedHeader,"authorization",
- "~n <www_authenticate userid=~p passwd=~p />"),
io:format(Fd,"</http></request>~n",[]),
{ok,State#state_rec{prev_port=NewPort,prev_host=NewHost,prev_scheme=NewScheme}}.
View
2 tsung-1.0.dtd
@@ -116,7 +116,7 @@
contents CDATA #IMPLIED
content_type CDATA #IMPLIED
if_modified_since CDATA #IMPLIED
- method (GET | POST | PUT | DELETE | HEAD | PROPFIND | PROPPATCH | COPY | MOVE | LOCK | UNLOCK | MKCOL | REPORT | VERSION-CONTROL ) "GET"
+ method (GET | POST | PUT | DELETE | HEAD | PROPFIND | PROPPATCH | COPY | MOVE | LOCK | UNLOCK | MKCOL | OPTIONS | REPORT | VERSION-CONTROL ) "GET"
url CDATA #REQUIRED
version (1.0 | 1.1) "1.1" >

0 comments on commit 1fe17e0

Please sign in to comment.
Something went wrong with that request. Please try again.