Commit graph

22 commits

Author SHA1 Message Date
asiva 75de086f1d [VM/Libraries] Fix all errors reported by CFE when the option
performNnbdChecks is turned on.

Bug:40424
Change-Id: I97a283c4a2d54f570def04d938baa9a4ced08667
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137250
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-03-02 23:03:51 +00:00
Zichang Guo 361f881b8e fix nnbd websocket
This fixes web_socket_typed_data_test and web_socket_test

Change-Id: I7200ba423dbe24857854ba600f9fb9b3d4757635
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135620
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2020-02-15 03:40:00 +00:00
Zichang Guo d39cdf03f8 Reland [dart:io] Stop forcing lower case on HttpHeaders
This is a breaking change. Request: https://github.com/dart-lang/sdk/issues/33501

HttpHeaders use lowercase by default for all headers, since it is supposed to be case insensitive. Some servers incorrectly treat case as significant, however, and expect headers with capitalization or in uppercase. The current implementation forces headers to be lower cases when adding values. Users cannot even manually modify the headers.

This change removes this restriction here so that users can modify the headers to whatever form they want. The new behavior is backwards compatible except if class was implemented. All headers inside http.dart are written as lower cases, adding values to HttpHeaders is still receiving lower cases input.

The other cl (https://dart-review.googlesource.com/c/http_multi_server/+/121411) migrates multi_headers.dart to be compatible with this change.

Bug: https://github.com/dart-lang/sdk/issues/33501
Change-Id: Ieb9f4061b27ed3bbc6d82e6a408c77d11abb037b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135357
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2020-02-14 22:23:17 +00:00
Zichang Guo fb7e6ba494 fix nnbd http parsing bug for http_headers_test
This fixs part of http_headers_test. The rest is because HeaderValue becomes non-nullable(in this cl https://dart-review.googlesource.com/c/sdk/+/134722).

Change-Id: Id1aad86363564986dba5282a9983924252ae0ecb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135530
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2020-02-13 00:49:29 +00:00
Zichang Guo 91eee195fc [http] loosen status code constraints and rephrase some http exceptions
1. Remove limitation of http response status code check. It used to be [100, 599]. Extends range to [0, 999] to allow users to use customized status code.
2. Rephrase some http exceptions to be more informative.
3. Possibly a bug in isHead setter, where it is only allowed to set to true.

Bug: https://github.com/dart-lang/sdk/issues/38898
Change-Id: I77d8d66eb8333dec1f53742821860b802f74f680
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134763
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-02-12 22:21:57 +00:00
Zichang Guo e0621b65b2 [nnbd] Stop writing chunked into headers
There are some tests failed after switching to NNBD. This is supposed to fix HttpException: Connection closed while receiving data.

It reduced the number of failure from 300 to 70.

The root cause is that HttpHeaders write {Transfer-Encoding: chunked} into _header field once user set it to true. However, when user tried to flip the bit,
remove() function didn't remove the content. This leads to an additional property in header. Parser alarmed when parsing it.

This is inconsistency on how others handle chunked transfer encoding. Looking at add(), set() and remove() implementation, all of them will only set _chunkedTransferEncoding instead of actually touching _header.

Bug: https://github.com/dart-lang/sdk/issues/40534
Change-Id: I80d76f3a6da01022fdb8e755e0def8a630ca376a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135353
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2020-02-12 19:36:47 +00:00
Jonas Termansen 02ced42875 [nnbd] Fix remaining NNBD errors in dart:_http and dart:io.
HeaderValue parameters must have non-null values per the specification.

Bug: https://github.com/dart-lang/sdk/issues/40040
Change-Id: I39f8c894015197c014057888026e4ad474aa5dc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134722
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2020-02-07 14:31:09 +00:00
Zichang Guo 91a3ea89c8 Revert "[dart:io] Stop forcing lower case on HttpHeaders"
This reverts commit b2b7337ad4.

Reason for revert: flutter build broke!!

Original change's description:
> [dart:io] Stop forcing lower case on HttpHeaders
> 
> This is a breaking change. Request: https://github.com/dart-lang/sdk/issues/33501
> 
> HttpHeaders use lowercase by default for all headers, since it is supposed to be case insensitive. Some servers incorrectly treat case as significant, however, and expect headers with capitalization or in uppercase. The current implementation forces headers to be lower cases when adding values. Users cannot even manually modify the headers.
> 
> This change removes this restriction here so that users can modify the headers to whatever form they want. The new behavior is backwards compatible except if class was implemented. All headers inside http.dart are written as lower cases, adding values to HttpHeaders is still receiving lower cases input.
> 
> The other cl (https://dart-review.googlesource.com/c/http_multi_server/+/121411) migrates multi_headers.dart to be compatible with this change.
> 
> Bug: https://github.com/dart-lang/sdk/issues/33501
> Change-Id: I6f7f2ef907b229773c283140c07f2de4cd500981
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119100
> Commit-Queue: Zichang Guo <zichangguo@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>

TBR=whesse@google.com,sortie@google.com,lrn@google.com,zichangguo@google.com

Change-Id: I4d4299393ad6549b250053df8823e726855e2baf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/33501
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134102
Reviewed-by: Zichang Guo <zichangguo@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2020-01-31 22:32:22 +00:00
Zichang Guo b2b7337ad4 [dart:io] Stop forcing lower case on HttpHeaders
This is a breaking change. Request: https://github.com/dart-lang/sdk/issues/33501

HttpHeaders use lowercase by default for all headers, since it is supposed to be case insensitive. Some servers incorrectly treat case as significant, however, and expect headers with capitalization or in uppercase. The current implementation forces headers to be lower cases when adding values. Users cannot even manually modify the headers.

This change removes this restriction here so that users can modify the headers to whatever form they want. The new behavior is backwards compatible except if class was implemented. All headers inside http.dart are written as lower cases, adding values to HttpHeaders is still receiving lower cases input.

The other cl (https://dart-review.googlesource.com/c/http_multi_server/+/121411) migrates multi_headers.dart to be compatible with this change.

Bug: https://github.com/dart-lang/sdk/issues/33501
Change-Id: I6f7f2ef907b229773c283140c07f2de4cd500981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119100
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2020-01-31 17:08:52 +00:00
Zichang Guo 06fa701c95 [http] fix hanging when parser failed to parser body of response/request
* Some cleanups on http parser.
* When parsing body of the http response/request, errors should not go to _controller, where it is paused. This leads to hanging.
* Fix another bug: (byte < 0x30 && 0x39 < byte)

Bug: https://github.com/dart-lang/sdk/issues/40132

Change-Id: Iaf3fb6a409c92889f50b86220a2c6c2318012c47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132964
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2020-01-28 23:43:42 +00:00
Lasse Reichstein Holst Nielsen 95511b314c Stop using List() constructor in NNBD code.
The List constructor has been disallowed in NNBD code, so the NNBD SDK
should not be using it.

This changes all uses, not just in the already migrated libraries.
(Also found some bad typing in the `RegExpMatch` class along the way).

Change-Id: Ic61bd64427c0961c23aaf7ce59af5c2c271890ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132282
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-01-24 15:59:29 +00:00
jonahwilliams 8c2ecadf70 [http] cleanups in sdk/sdk_nnbd
Attempt some basic cleanups in both sdk/sdk_nnbd _http library

* Replace references to deprecated constants
* Remove unused catch clauses from sdk _http
* Remove unused code from sdk _http
* Fix typo in sdk_nnbd _http
* replace int.parse/onError with tryParse/??

Change-Id: Ifbffa0867653cb117560473d956d0c62dd19af6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129982
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2020-01-10 16:52:37 +00:00
Lasse Reichstein Holst Nielsen b431cbc6c6 Migrate dart:_http to NNBD.
Change-Id: I2a27ebcb06776637411021a62d29daf80dae0850
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126649
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2019-12-16 13:49:40 +00:00
Jonas Termansen daa400bada [sdk] Fix all uses of the view() constructor to always use offsetInBytes.
The list being viewed can sometimes itself be a sublist view, but the
default view() constructor doesn't take that into account, and instead the
caller needs to be aware of the case. This change makes all such uses use
offsetInBytes, even in cases that's not needed, so it's trivial to audit
that it's always used correctly. In the cases it's not needed, it just gets
the value 0 and it's a no-operation. In the cases it's needed, it fixes a
bug, such as in _WebSocketProtocolTransformer.add().

Closes #39589

Change-Id: I6e9bd5510f48ce378bdec2c64b56fe789dfb27ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127165
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2019-12-06 10:37:00 +00:00
Kevin Moore 8342ec2c71 Fix pub.dev URLs throughout SDK repo
Change-Id: I5bcb7c40be12ee1dc887620281b4807469d67bbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125729
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2019-11-20 11:30:48 +00:00
Ben Konyi cfd226a27f [ dart:http ] Fix issue where setting HttpClient.enableTimelineLogging wasn't actually enabling timeline logging
Change-Id: I12134eaf1cd79516376d266b9919535987f7703b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125565
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2019-11-18 22:17:55 +00:00
Ben Konyi 1c12878d05 [ dart:io ] Added timeline events for HttpClient connections and requests
Setting the `enableTimelineLogging` property of `HttpClient` to true results in
timeline events being created for HTTP connections and HTTP requests.
Timeline events contain general connection information, including:
  - Request type
  - Status code
  - Request / response headers
  - Cookies
  - Non-sensitive proxy information
  - Relevent error messages for failed connections

Change-Id: Ibe16a312ab5398c9ae886ea07bea5ca70b63e440
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123540
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-11-16 00:46:46 +00:00
Zichang Guo 4366afc6f5 [http] noFolding() should follow same check as add()
Walk through http headers class. Since http header uses case-insensitive headers, noFolding() implicitly assumes field name is lower-cases. It is used to compare to lower-cases field name. Validate the field name before it is stored and also add a test case for noFolding().

Change-Id: I58f8a0ed0d366281e1e7a8c60fd46ff81c8ee796
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121773
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2019-11-11 16:36:23 +00:00
Zichang Guo 2741022aa0 [vm/http] replace hard coded string in http headers
Working on a fix to not force http headers to be lowercases.
Most of headers are listed in http.dart like HttpHeaders.acceptHeader. But there are some places which use hard code string("Accept") to refer to certain header.
Replace raw strings for consistency.

Change-Id: Ieba77428173123b7b144885ab5c92642d63de580
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118649
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-09-26 15:01:52 +00:00
Lasse R.H. Nielsen e88057fe04 Add non-NNBD language version marker on all sdk_nnbd files.
Change-Id: I2ab3d4b1efe0f3c79f4b770e79476153380220f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118040
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2019-09-19 19:44:37 +00:00
Alexander Markov d0052c1b31 [dart:_http] Fix potentially large List<int> allocation in _WebSocketPerMessageDeflate.processIncomingMessage
processIncomingMessage() was creating List<int> to hold uncompressed bytes,
which is very wastefull if size of the message is large (spending a word
for each byte).

Changed processIncomingMessage() to use BytesBuilder for uncompressed bytes.

This fixes flaky out of memory failure on service/get_vm_timeline_rpc_test with
bytecode in dartk-optcounter-linux-release-ia32 configuration. In that test size of
uncompressed message exceeded 130MB, causing 1GB memory allocation (512MB List
was expanded).

Change-Id: Ic5a78a13bd431f5ad97496907a84a3f7ba01c1fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117121
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-09-13 17:07:16 +00:00
Paul Berry 004d49bd6b Make a fork of sdk/lib for use by NNBD.
Change-Id: I7f5892d66f9e7bd08ca064fb2df329794a56faf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116527
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-09-10 19:20:12 +00:00