Skip to content

Commit 1d4acba

Browse files
authored
Support Firefox (flutter#13)
* Support firefox
1 parent e43d071 commit 1d4acba

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

.travis.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
language: dart
2-
# This is necessary to use proper Chrome. Travis's version of chromium is from
3-
# 2014.
42
sudo: required
5-
dist: trusty
63
addons:
74
chrome: stable
8-
apt:
9-
sources:
10-
- google-chrome
11-
packages:
12-
- google-chrome-stable
13-
firefox: latest
145

156
dart:
167
- dev
@@ -19,18 +10,14 @@ dart:
1910
with_content_shell: false
2011

2112
before_install:
22-
- export CHROMEDRIVER_BINARY=/usr/bin/google-chrome
23-
- export CHROMEDRIVER_ARGS=--no-sandbox
24-
- /usr/bin/google-chrome --version
25-
- export DISPLAY=:99.0
26-
- sh -e /etc/init.d/xvfb start
27-
28-
before_script:
13+
- "export CHROMEDRIVER_BINARY=/usr/bin/google-chrome"
14+
- "export CHROMEDRIVER_ARGS=--no-sandbox"
15+
- "/usr/bin/google-chrome --version"
2916
- "export CHROME_LATEST_VERSION=$(/usr/bin/google-chrome --version | cut -d' ' -f3 | cut -d'.' -f1)"
3017
- "export CHROME_DRIVER_VERSION=$(wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_LATEST_VERSION)"
3118
- "wget https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip"
3219
- unzip chromedriver_linux64.zip
33-
- export PATH=$PATH:$PWD
20+
- "export PATH=$PATH:$PWD"
3421
- ./tool/travis-setup.sh
3522

3623
script:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.0
2+
3+
- Support Firefox.
4+
15
## 2.0.3
26

37
- Fix an issue where messages could come out of order.

lib/server/sse_handler.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import 'package:shelf/shelf.dart' as shelf;
1212
import 'package:stream_channel/stream_channel.dart';
1313

1414
String _sseHeaders(String origin) => 'HTTP/1.1 200 OK\r\n'
15-
'Content-Type: text/event-stream\r\n'
16-
'Cache-Control: no-cache\r\n'
17-
'Connection: keep-alive\r\n'
18-
'Access-Control-Allow-Credentials: true\r\n'
19-
'Access-Control-Allow-Origin: $origin\r\n'
20-
'\r\n';
15+
'Content-Type: text/event-stream\n\n'
16+
'Cache-Control: no-cache\n\n'
17+
'Connection: keep-alive\n\n'
18+
'Access-Control-Allow-Credentials: true\n\n'
19+
'Access-Control-Allow-Origin: $origin\n\n'
20+
'\n\n';
2121

2222
/// A bi-directional SSE connection between server and browser.
2323
class SseConnection extends StreamChannelMixin<String> {
@@ -140,7 +140,12 @@ class SseHandler {
140140
}
141141
return shelf.Response.ok('', headers: {
142142
'access-control-allow-credentials': 'true',
143-
'access-control-allow-origin': req.headers['origin']
143+
'access-control-allow-origin': _originFor(req),
144144
});
145145
}
146+
147+
String _originFor(shelf.Request req) =>
148+
// Firefox does not set header "origin".
149+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1508661
150+
req.headers['origin'] ?? req.headers['host'];
146151
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sse
2-
version: 2.0.3
2+
version: 2.1.0
33
author: Dart Team <[email protected]>
44
homepage: https://github.com/dart-lang/sse
55
description: >-

0 commit comments

Comments
 (0)