aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_client
AgeCommit message (Collapse)Author
2019-06-27inets: Return error if URI has no scheme (httpc)Péter Dimitrov
This commit fixes a regression and changes httpc to return {error, no_scheme} when the request URI has no scheme e.g. "//foobar".
2019-02-04Merge branch 'maint'Péter Dimitrov
* maint: Fix typo in erlang.xml inets: Ignore bracket option in format_address Change-Id: I8a215d3872ae74e08d7a17b70ba53535947c032f
2019-02-01inets: Ignore bracket option in format_addressPéter Dimitrov
Ignore the option 'ipv6_host_with_brackets' when formatting addresses to be used in lower level functions. Change-Id: I3b7b276b37fe129ade9208519bff226e17ae7c57
2019-01-23Merge branch 'maint'Ingela Anderton Andin
2019-01-23inets: httpc - Do not use bracked addresses to gen_tcp or ssl callsIngela Anderton Andin
2018-10-08Merge branch 'maint'Péter Dimitrov
* maint: inets: Fix handling of 'Content-Type' (httpc) inets: Fix handling of 'Content-Length' (httpc) Change-Id: I3c8b4ef664d1888efb87d7799365df66eb4b2ff3
2018-10-08Merge branch 'peterdmv/inets/httpc-content-type/ERL-736/OTP-15339' into maintPéter Dimitrov
* peterdmv/inets/httpc-content-type/ERL-736/OTP-15339: inets: Fix handling of 'Content-Type' (httpc) Change-Id: I8c9f48d8474dba7a83e4ecba6b8146faffb559fc
2018-10-02inets: Fix handling of 'Content-Type' (httpc)Péter Dimitrov
'Content-Type' is sent when it is explicitly set as a header or there is a non-empty body in the request. Former implementation dropped the explicit 'Content-Type' when the request had an empty body. Change-Id: I00a9e4a5011f9d28c04c0dfc5fe1561b1ab7eb09
2018-10-02inets: Fix handling of 'Content-Length' (httpc)Péter Dimitrov
RFC7230 3.3.2 A sender MUST NOT send a 'Content-Length' header field in any message that contains a 'Transfer-Encoding' header field. Change-Id: I568fc65cafe3ab30baad56c002459ff74e4dbb28
2018-08-28Merge pull request #1894 from CrowdHailer/patch-1Ingela Andin
Update httpc_manager.erl to fix typo
2018-08-27Merge branch 'maint'Péter Dimitrov
* maint: inets: Prepare for release inets: Robust handling of 204, 304, 1xx responses inets: Do not use chunked encoding with 1xx, 204, 304 Change-Id: Ia739a7b1a7f1482194def99d039b5a7c8133a6ca
2018-08-27Merge branch 'maint-20' into maintPéter Dimitrov
* maint-20: inets: Prepare for release inets: Robust handling of 204, 304, 1xx responses inets: Do not use chunked encoding with 1xx, 204, 304 Change-Id: Ia88eb1d217b46fb01b1d7544d9ef34788c87abbd
2018-08-24inets: Robust handling of 204, 304, 1xx responsesPéter Dimitrov
All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a message-body, and thus are always terminated by the first empty line after the header fields. This implies that chunked encoding MUST NOT be used for these status codes. This commit updates the client to gracefully handle responses from faulty server implementations that can send chunked encoded 204, 304 or 1xx responses. Change-Id: I2dd502e28b3c6e121640083118fa5c3e479f5194
2018-07-27Change "can not" into "cannot"Raimo Niskanen
I did not find any legitimate use of "can not", however skipped changing e.g RFCs archived in the source tree.
2018-07-26Update httpc_manager.erlPeter Saxton
2018-07-09Merge branch 'maint'Péter Dimitrov
* maint: Don't modify URI, explicitly pass scheme to get_port Update scheme on redirect URI and accumulator Fix accidental Port assertion in resolve_authority Add test case on relative redirects with ports Do not assert that new URI port is same as old port Add mixed test group, http -> https redirect test Change-Id: I23b976dbc64e19787d6eca5757df50a1b7098857
2018-07-06Don't modify URI, explicitly pass scheme to get_portRoss Schlaikjer
2018-07-06Update scheme on redirect URI and accumulatorRoss Schlaikjer
This is necessary to prevent an error when calling get_port inside resolve_authority
2018-07-06Fix accidental Port assertion in resolve_authorityRoss Schlaikjer
2018-07-06Do not assert that new URI port is same as old portRoss Schlaikjer
When handling 301 redirects from http -> https on Erlang 21.0.1, the following error is encountered: ``` 8> Options = []. 9> httpc:request(head, {"http://rhye.org", []}, Options, []). {error,{shutdown,{{error,{badmatch,443}}, [{httpc_response,resolve_uri,7, [{file,"/usr/local/lib/erlang/lib/inets-7.0/src/http_client/httpc_response.erl"}, {line,431}]}, {httpc_response,redirect,2, [{file,"/usr/local/lib/erlang/lib/inets-7.0/src/http_client/httpc_response.erl"}, {line,396}]}, {httpc_handler,handle_response,1, [{file,"httpc_handler.erl"},{line,1052}]}, {httpc_handler,handle_info,2, [{file,"httpc_handler.erl"},{line,283}]}, {gen_server,try_dispatch,4, [{file,"gen_server.erl"},{line,637}]}, {gen_server,handle_msg,6, [{file,"gen_server.erl"},{line,711}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,249}]}]}}} ``` This seems to be caused by the following code in `resolve_uri`: ``` resolve_uri(Scheme, Host, Port, Path, Query, URI, Map0) -> case maps:is_key(scheme, URI) of true -> Port = get_port(URI) ``` The value of `Port` passed in to `resolve_uri` here is 80, since the original URL is http. However, since the redirected URL is https, the `get_port` call returns 443, which is not equal to 80, and crashes. Assigning to a new variable seems to fix redirects.
2018-06-30Include question mark in query string on redirectJosé Valim
According to the code in httpc.erl, the pquery parameter in the #request record should start with a question mark. However, when a server returned a 403 response, the Location header was parsed and the question mark was not added to the beginning of the query string. This ultimately causes the redirect to fail, as instead of redirecting to "/path?query", httpc redirected to "/pathquery".
2018-06-18Update copyright yearHenrik Nord
2018-04-27inets: Improve httpc gracefulnessIngela Anderton Andin
This commit will make the close down sequence work as intended, and no crash report will be generated. Alas such error corner cases are hard to write automated test for.
2018-04-19inets: Fix broken httpc options handlingPéter Dimitrov
- Add support for setting socket options per request. - Add http_ipv6 test group. Change-Id: Ia2aca37c0b5fe64a41995c79ae3399434b17ab8a
2018-04-17Merge branch 'maint'Péter Dimitrov
* maint: inets: Fix broken httpc options handling Change-Id: I9e44f0e53237a390048cab3aaf52ea0e1a5358a2
2018-04-17Merge branch 'peterdmv/httpc_delete_requests/ERL-536/OTP-15006'Péter Dimitrov
* peterdmv/httpc_delete_requests/ERL-536/OTP-15006: inets: Fix broken handling of header Content-Type Change-Id: I8d6f23d830961f71a198377351f14b0e97dcd44b
2018-04-12inets: Fix broken httpc options handlingPéter Dimitrov
- Add support for setting socket options per request. - Add http_ipv6 test group. Change-Id: Ia2aca37c0b5fe64a41995c79ae3399434b17ab8a
2018-04-06inets: Improve readability of handling of server `Connection: close`Luca Favatella
Addresses https://github.com/erlang/otp/pull/1752#discussion_r177970060
2018-04-06inets: Fix broken handling of header Content-TypePéter Dimitrov
Strict REST APIs does not accept HTTP requests that have no body but still include a 'Content-Type' header. RFC7231 does not forbid this corner case but as it causes interoperatbility problems in client software we opt to not send the 'Content-Type' header when the body is not present. Change-Id: I36c43225fd156fb1b651037fcbe69b448665ec23
2018-04-05inets: Avoid `erlang:get_stacktrace/0` deprecated in OTP 21Luca Favatella
2018-03-23inets: Teach httpc to honour `Connection: close` from serverLuca Favatella
From https://tools.ietf.org/html/rfc7230#section-6.6 > A client that receives a "close" connection option MUST cease sending requests on that connection and close the connection after reading the response message containing the "close"; if additional pipelined requests had been sent on the connection, the client SHOULD NOT assume that they will be processed by the server. Notes on tests: * The new tests are added only in group sim_http and not sim_https because the same test approach appears to be not valid because when processing the first response the server already sent data (> 0) for the TLS/SSL handshake; * The order of tests is relevant as it appears some test cases leave reusable sessions behind.
2018-03-23inets: Make httpc error reason more informative for unexpected errorsLuca Favatella
2018-03-23inets: Enable stronger Dialyzer checks in httpc_handlerLuca Favatella
2018-03-23inets: Remove httpc dead code re init errorLuca Favatella
... i.e. references to `connect_failed` and `send_failed`, unused since 5d32eaf750 .
2018-03-23inets: Delete obsolete comment in httpc_response:resultLuca Favatella
2018-03-06Merge branch 'maint'Péter Dimitrov
* maint: inets: Prepare for release inets: Skip http_unix_socket test group on Windows inets: Add unix domain socket support to httpc Change-Id: I4c3a3d6e4fbbdf82e4e2e7d30b84510f9c286c68
2018-02-26inets: Add unix domain socket support to httpcPéter Dimitrov
Change-Id: I44fe2670e36884e09600d17dd71b1e86b9ee75fa
2018-02-19Merge branch 'maint'Péter Dimitrov
* maint: inets: Prepare for release inets: Fix httpc crash on keep-alive connections Change-Id: If066f788c3fcb8b5c5a943892d3c03c201590e40
2018-02-09inets: Fix httpc crash on keep-alive connectionsPéter Dimitrov
- Set gen_server call timeout to infinity in httpc_handler. - Add new testcase 'slow_connection'. Change-Id: Id11b54c588e1d66b9ebba4da5dbfe5e9bee1f1ee
2018-02-05inets: Do not call erlang:get_stacktrace()Hans Bolinder
2017-11-28inets: Fix httpc path handlingPéter Dimitrov
Fixed handling of URL paths that contain space (%20) characters. Change-Id: Ic09691e35c70ee005af7637a6ec3ae588097bec1
2017-11-20Merge branch 'peterdmv/inets/autoredirect/ERL-333/OTP-14729'Péter Dimitrov
* peterdmv/inets/autoredirect/ERL-333/OTP-14729: inets: Add support for URI-references in Location
2017-11-20Merge branch 'peterdmv/inets/http_content_injection/ERL-456/OTP-14726'Péter Dimitrov
* peterdmv/inets/http_content_injection/ERL-456/OTP-14726: inets: Fix http content injection bug in httpc
2017-11-17inets: Eliminate race conditionIngela Anderton Andin
Only run test case for http as the socket manipulation done by the test case requires much more manipulation to work for https. However, that this test case started failing constantly instead of sporadically is proof that this change is a good thing.
2017-11-15inets: Fix http content injection bug in httpcPéter Dimitrov
- uri_string module used for parsing URIs. - Removed url_encode option as only valid URIs shall be handled by the http client. - The client rejects URIs that are not compliant with RFC 3986. Change-Id: I0a5b9766f6463a9802e0b02b445a2c4c91f02236
2017-11-15inets: Add support for URI-references in LocationPéter Dimitrov
RFC 2616 requires an absolute URI in 'Location' header field for redirects. RFC 7231 obsoleted RFC 2616 and allows URI-references. Updated httpc_response to support URI-references, based on the URI resolution algorithm defined by RFC 3986 (5.2.2. Transform References). Change-Id: I42227d32f458b6e7a60d55b40407c4092e69b222
2017-10-29[#ERL-407]: Fix httpc misbehaviour based on RFC7230, section 3.3.3Hamidreza Soleimani
If a message is received with both a Transfer-Encoding and a Content-Length header field, it might indicate an attempt to perform request smuggling or response splitting and must be handled as an error in default mode (not relaxed mode). Bug report: https://bugs.erlang.org/browse/ERL-407
2017-10-26inets: Correct guard testIngela Anderton Andin
Guard test for error case was not updated to handle httpc stream concept properly.
2017-06-14Update copyright yearHans Nilsson
2017-05-30inets: httpc - Gracefull normal shutdownIngela Anderton Andin