cmullaparthi / ibrowse

Erlang HTTP client
Other
516 stars 190 forks source link

send_req/5 Options and Headers arguments inverted #109

Closed unbalancedparentheses closed 10 years ago

unbalancedparentheses commented 10 years ago

The wiki states:

send_req(Url::string(), Headers::headerList(), Method::method(), Body::body(), Options::optionList()) -> response()
optionList() = [option()]
option() = {max_sessions, integer()} | {response_format, response_format()} | {stream_chunk_size, integer()} | {max_pipeline_size, integer()} | {trace, boolean()} | {is_ssl, boolean()} | {ssl_options, [SSLOpt]} | {pool_name, atom()} | {proxy_host, string()} | {proxy_port, integer()} | {proxy_user, string()} | {proxy_password, string()} | {use_absolute_uri, boolean()} | {basic_auth, {username(), password()}} | {cookie, string()} | {content_length, integer()} | {content_type, string()} | {save_response_to_file, srtf()} | {stream_to, stream_to()} | {http_vsn, {MajorVsn, MinorVsn}} | {host_header, string()} | {inactivity_timeout, integer()} | {connect_timeout, integer()} | {socket_options, Sock_opts} | {transfer_encoding, {chunked, ChunkSize}} | {headers_as_is, boolean()} | {give_raw_headers, boolean()} | {preserve_chunked_encoding, boolean()} | {workaround, head_response_with_body}

However if I use it as the wiki states the options are not sent:

    Url = "http://localhost:8080/"
    Headers = []
    Body = [],
    Options = [{content_type, "application/json"}, {basic_auth, {"test", "test"}}],
    ibrowse:send_req(Url, Headers, post, Body, Options)

If it put the options on the header they are sent and everything works fine:

    Url = "http://localhost:8080/"
    Headers = [{content_type, "application/json"}, {basic_auth, {"test", "test"}}],
    Body = [],
    Options = [],
    ibrowse:send_req(Url, Headers, post, Body, Options)
cmullaparthi commented 10 years ago

Fair point. I think the problem is that the basic_auth option works whether you supply it in the Headers or Options. Whereas content_type works as advertised i.e only in the 'Options' parameter.

I'll add a note to that effect and leave the behaviour as it is.