Skip to content
This repository

add missing methods #66

Merged
merged 2 commits into from over 2 years ago

2 participants

Benoit Chesneau Chandrashekhar Mullaparthi
Benoit Chesneau

This patch add some missing HTTP verbs to ibrowse to be abble to discuss with subversion & upnp devices.

Chandrashekhar Mullaparthi
Owner

Thank you Benoit. Are these changes tested? :-)

Chandrashekhar Mullaparthi cmullaparthi merged commit 7265dbc into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Mar 27, 2012
Benoit Chesneau benoitc whitespaces 67eea91
Benoit Chesneau benoitc add missing methods and reorder them by type. f8ebe0b
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 49 additions and 35 deletions. Show diff stats Hide diff stats

  1. +49 35 src/ibrowse_http_client.erl
84 src/ibrowse_http_client.erl
@@ -46,7 +46,7 @@
46 46 reqs=queue:new(), cur_req, status=idle, http_status_code,
47 47 reply_buffer = <<>>, rep_buf_size=0, streamed_size = 0,
48 48 recvd_headers=[],
49   - status_line, raw_headers,
  49 + status_line, raw_headers,
50 50 is_closing, content_length,
51 51 deleted_crlf = false, transfer_encoding,
52 52 chunk_size, chunk_size_buffer = <<>>,
@@ -55,11 +55,11 @@
55 55 }).
56 56
57 57 -record(request, {url, method, options, from,
58   - stream_to, caller_controls_socket = false,
  58 + stream_to, caller_controls_socket = false,
59 59 caller_socket_options = [],
60 60 req_id,
61 61 stream_chunk_size,
62   - save_response_to_file = false,
  62 + save_response_to_file = false,
63 63 tmp_file_name, tmp_file_fd, preserve_chunked_encoding,
64 64 response_format, timer_ref}).
65 65
@@ -204,7 +204,7 @@ handle_info({stream_close, _Req_id}, State) ->
204 204 do_error_reply(State, closing_on_request),
205 205 {stop, normal, State};
206 206
207   -handle_info({tcp_closed, _Sock}, State) ->
  207 +handle_info({tcp_closed, _Sock}, State) ->
208 208 do_trace("TCP connection closed by peer!~n", []),
209 209 handle_sock_closed(State),
210 210 {stop, normal, State};
@@ -402,7 +402,7 @@ accumulate_response(Data, #state{reply_buffer = RepBuf,
402 402 State#state{reply_buffer = RepBuf_1};
403 403 _ when Caller_controls_socket == true ->
404 404 do_interim_reply(StreamTo, Response_format, ReqId, RepBuf_1),
405   - State#state{reply_buffer = <<>>,
  405 + State#state{reply_buffer = <<>>,
406 406 interim_reply_sent = true,
407 407 streamed_size = Streamed_size + size(RepBuf_1)};
408 408 _ when New_data_size >= Stream_chunk_size ->
@@ -710,7 +710,7 @@ send_req_1(From,
710 710 {stop, normal, State_1}
711 711 end;
712 712
713   -send_req_1(From, Url, Headers, Method, Body, Options, Timeout,
  713 +send_req_1(From, Url, Headers, Method, Body, Options, Timeout,
714 714 #state{proxy_tunnel_setup = in_progress,
715 715 tunnel_setup_queue = Q} = State) ->
716 716 do_trace("Queued SSL request awaiting tunnel setup: ~n"
@@ -734,7 +734,7 @@ send_req_1(From,
734 734 {Caller, once} when is_pid(Caller) or
735 735 is_atom(Caller) ->
736 736 Async_pid_rec = {{req_id_pid, ReqId}, self()},
737   - true = ets:insert(ibrowse_stream, Async_pid_rec),
  737 + true = ets:insert(ibrowse_stream, Async_pid_rec),
738 738 {Caller, true};
739 739 undefined ->
740 740 {undefined, false};
@@ -923,7 +923,7 @@ is_chunked_encoding_specified(Options) ->
923 923 case get_value(transfer_encoding, Options, false) of
924 924 false ->
925 925 false;
926   - {chunked, _} ->
  926 + {chunked, _} ->
927 927 true;
928 928 chunked ->
929 929 true
@@ -1034,7 +1034,7 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
1034 1034 put(conn_close, ConnClose),
1035 1035 TransferEncoding = to_lower(get_value("transfer-encoding", LCHeaders, "false")),
1036 1036 case get_value("content-length", LCHeaders, undefined) of
1037   - _ when Method == connect,
  1037 + _ when Method == connect,
1038 1038 hd(StatCode) == $2 ->
1039 1039 {_, Reqs_1} = queue:out(Reqs),
1040 1040 cancel_timer(T_ref),
@@ -1132,7 +1132,7 @@ parse_response(Data, #state{reply_buffer = Acc, reqs = Reqs,
1132 1132 {error, max_headers_size_exceeded}
1133 1133 end.
1134 1134
1135   -upgrade_to_ssl(#state{socket = Socket,
  1135 +upgrade_to_ssl(#state{socket = Socket,
1136 1136 connect_timeout = Conn_timeout,
1137 1137 ssl_options = Ssl_options,
1138 1138 tunnel_setup_queue = Q} = State) ->
@@ -1172,7 +1172,7 @@ is_connection_closing(_, _) -> false.
1172 1172
1173 1173 %% This clause determines the chunk size when given data from the beginning of the chunk
1174 1174 parse_11_response(DataRecvd,
1175   - #state{transfer_encoding = chunked,
  1175 + #state{transfer_encoding = chunked,
1176 1176 chunk_size = chunk_start,
1177 1177 chunk_size_buffer = Chunk_sz_buf
1178 1178 } = State) ->
@@ -1200,7 +1200,7 @@ parse_11_response(DataRecvd,
1200 1200 %% This clause is to remove the CRLF between two chunks
1201 1201 %%
1202 1202 parse_11_response(DataRecvd,
1203   - #state{transfer_encoding = chunked,
  1203 + #state{transfer_encoding = chunked,
1204 1204 chunk_size = tbd,
1205 1205 chunk_size_buffer = Buf
1206 1206 } = State) ->
@@ -1219,7 +1219,7 @@ parse_11_response(DataRecvd,
1219 1219 %% not support Trailers in the Chunked Transfer encoding. Any trailer
1220 1220 %% received is silently discarded.
1221 1221 parse_11_response(DataRecvd,
1222   - #state{transfer_encoding = chunked, chunk_size = 0,
  1222 + #state{transfer_encoding = chunked, chunk_size = 0,
1223 1223 cur_req = CurReq,
1224 1224 deleted_crlf = DelCrlf,
1225 1225 chunk_size_buffer = Trailer,
@@ -1308,9 +1308,9 @@ handle_response(#request{from=From, stream_to=StreamTo, req_id=ReqId,
1308 1308 recvd_headers = RespHeaders}=State) when SaveResponseToFile /= false ->
1309 1309 Body = RepBuf,
1310 1310 case Fd of
1311   - undefined ->
  1311 + undefined ->
1312 1312 ok;
1313   - _ ->
  1313 + _ ->
1314 1314 ok = file:close(Fd)
1315 1315 end,
1316 1316 ResponseBody = case TmpFilename of
@@ -1554,22 +1554,36 @@ fmt_val(Term) -> io_lib:format("~p", [Term]).
1554 1554
1555 1555 crnl() -> "\r\n".
1556 1556
1557   -method(connect) -> "CONNECT";
1558   -method(copy) -> "COPY";
1559   -method(delete) -> "DELETE";
1560   -method(get) -> "GET";
1561   -method(head) -> "HEAD";
1562   -method(lock) -> "LOCK";
1563   -method(mkcol) -> "MKCOL";
1564   -method(move) -> "MOVE";
1565   -method(options) -> "OPTIONS";
1566   -method(patch) -> "PATCH";
1567   -method(post) -> "POST";
1568   -method(propfind) -> "PROPFIND";
1569   -method(proppatch) -> "PROPPATCH";
1570   -method(put) -> "PUT";
1571   -method(trace) -> "TRACE";
1572   -method(unlock) -> "UNLOCK".
  1557 +method(connect) -> "CONNECT";
  1558 +method(delete) -> "DELETE";
  1559 +method(get) -> "GET";
  1560 +method(head) -> "HEAD";
  1561 +method(options) -> "OPTIONS";
  1562 +method(post) -> "POST";
  1563 +method(put) -> "PUT";
  1564 +method(trace) -> "TRACE";
  1565 +%% webdav
  1566 +method(copy) -> "COPY";
  1567 +method(lock) -> "LOCK";
  1568 +method(mkcol) -> "MKCOL";
  1569 +method(move) -> "MOVE";
  1570 +method(propfind) -> "PROPFIND";
  1571 +method(proppatch) -> "PROPPATCH";
  1572 +method(search) -> "SEARCH";
  1573 +method(unlock) -> "UNLOCK";
  1574 +%% subversion %%
  1575 +method(report) -> "REPORT";
  1576 +method(mkactivity) -> "MKACTIVITY";
  1577 +method(checkout) -> "CHECKOUT";
  1578 +method(merge) -> "MERGE";
  1579 +%% upnp
  1580 +method(msearch) -> "MSEARCH";
  1581 +method(notify) -> "NOTIFY";
  1582 +method(subscribe) -> "SUBSCRIBE";
  1583 +method(unsubscribe) -> "UNSUBSCRIBE";
  1584 +%% rfc-5789
  1585 +method(patch) -> "PATCH";
  1586 +method(purge) -> "PURGE".
1573 1587
1574 1588 %% From RFC 2616
1575 1589 %%
@@ -1623,8 +1637,8 @@ is_whitespace(_) -> false.
1623 1637
1624 1638 send_async_headers(_ReqId, undefined, _, _State) ->
1625 1639 ok;
1626   -send_async_headers(ReqId, StreamTo, Give_raw_headers,
1627   - #state{status_line = Status_line, raw_headers = Raw_headers,
  1640 +send_async_headers(ReqId, StreamTo, Give_raw_headers,
  1641 + #state{status_line = Status_line, raw_headers = Raw_headers,
1628 1642 recvd_headers = Headers, http_status_code = StatCode,
1629 1643 cur_req = #request{options = Opts}
1630 1644 }) ->
@@ -1845,7 +1859,7 @@ set_inac_timer(State, Timeout) when is_integer(Timeout) ->
1845 1859 set_inac_timer(State, _) ->
1846 1860 State.
1847 1861
1848   -get_inac_timeout(#state{cur_req = #request{options = Opts}}) ->
  1862 +get_inac_timeout(#state{cur_req = #request{options = Opts}}) ->
1849 1863 get_value(inactivity_timeout, Opts, infinity);
1850 1864 get_inac_timeout(#state{cur_req = undefined}) ->
1851 1865 case ibrowse:get_config_value(inactivity_timeout, undefined) of
@@ -1888,5 +1902,5 @@ trace_request_body(Body) ->
1888 1902 ok
1889 1903 end.
1890 1904
1891   -to_binary(X) when is_list(X) -> list_to_binary(X);
  1905 +to_binary(X) when is_list(X) -> list_to_binary(X);
1892 1906 to_binary(X) when is_binary(X) -> X.

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.