Merge branch 'master' into issue_template

This commit is contained in:
Yuki Okushi 2020-01-24 05:11:25 +09:00 committed by GitHub
commit 9203a4ffb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 27 deletions

View File

@ -3,7 +3,6 @@ name: CI (Windows)
on: [push, pull_request]
env:
VCPKG_HASH: 3f62e5d55d1a7d8905df35d5c441d6e9ad64ffdf
VCPKGRS_DYNAMIC: 1
jobs:
@ -47,27 +46,15 @@ jobs:
with:
path: target
key: ${{ matrix.version }}-x86_64-pc-windows-msvc-cargo-build-${{ hashFiles('**/Cargo.lock') }}
- name: Cache vcpkg package
uses: actions/cache@v1
id: cache-vcpkg
with:
path: vcpkg
key: windows_x64-${{ env.VCPKG_HASH }}-vcpkg
- name: Install OpenSSL
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
shell: pwsh
run: |
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
git reset --hard $VCPKG_HASH
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
.\vcpkg install openssl:x64-windows
Copy-Item .\installed\x64-windows\bin\libcrypto-1_1-x64.dll .\installed\x64-windows\bin\libcrypto.dll
Copy-Item .\installed\x64-windows\bin\libssl-1_1-x64.dll .\installed\x64-windows\bin\libssl.dll
Get-ChildItem .\installed\x64-windows\bin
Get-ChildItem .\installed\x64-windows\lib
vcpkg integrate install
vcpkg install openssl:x64-windows
Copy-Item C:\vcpkg\installed\x64-windows\bin\libcrypto-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libcrypto.dll
Copy-Item C:\vcpkg\installed\x64-windows\bin\libssl-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libssl.dll
Get-ChildItem C:\vcpkg\installed\x64-windows\bin
Get-ChildItem C:\vcpkg\installed\x64-windows\lib
- name: check build
uses: actions-rs/cargo@v1

View File

@ -1,3 +1,9 @@
## Unreleased
* Setting a cookie's SameSite property, explicitly, to `SameSite::None` will now
result in `SameSite=None` being sent with the response Set-Cookie header.
To create a cookie without a SameSite attribute, remove any calls setting same_site.
## 2.0.0
* `HttpServer::start()` renamed to `HttpServer::run()`. It also possible to

View File

@ -1,5 +1,11 @@
# Changes
# [Unreleased]
### Fixed
* Allow `SameSite=None` cookies to be sent in a response.
## [1.0.1] - 2019-12-20
### Fixed

View File

@ -10,18 +10,26 @@ use std::fmt;
/// attribute is "Strict", then the cookie is never sent in cross-site requests.
/// If the `SameSite` attribute is "Lax", the cookie is only sent in cross-site
/// requests with "safe" HTTP methods, i.e, `GET`, `HEAD`, `OPTIONS`, `TRACE`.
/// If the `SameSite` attribute is not present (made explicit via the
/// `SameSite::None` variant), then the cookie will be sent as normal.
/// If the `SameSite` attribute is not present then the cookie will be sent as
/// normal. In some browsers, this will implicitly handle the cookie as if "Lax"
/// and in others, "None". It's best to explicitly set the `SameSite` attribute
/// to avoid inconsistent behavior.
///
/// **Note:** Depending on browser, the `Secure` attribute may be required for
/// `SameSite` "None" cookies to be accepted.
///
/// **Note:** This cookie attribute is an HTTP draft! Its meaning and definition
/// are subject to change.
///
/// More info about these draft changes can be found in the draft spec:
/// - https://tools.ietf.org/html/draft-west-cookie-incrementalism-00
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SameSite {
/// The "Strict" `SameSite` attribute.
Strict,
/// The "Lax" `SameSite` attribute.
Lax,
/// No `SameSite` attribute.
/// The "None" `SameSite` attribute.
None,
}
@ -92,7 +100,7 @@ impl fmt::Display for SameSite {
match *self {
SameSite::Strict => write!(f, "Strict"),
SameSite::Lax => write!(f, "Lax"),
SameSite::None => Ok(()),
SameSite::None => write!(f, "None"),
}
}
}

View File

@ -746,9 +746,7 @@ impl<'c> Cookie<'c> {
}
if let Some(same_site) = self.same_site() {
if !same_site.is_none() {
write!(f, "; SameSite={}", same_site)?;
}
write!(f, "; SameSite={}", same_site)?;
}
if let Some(path) = self.path() {
@ -1037,7 +1035,7 @@ mod tests {
let cookie = Cookie::build("foo", "bar")
.same_site(SameSite::None)
.finish();
assert_eq!(&cookie.to_string(), "foo=bar");
assert_eq!(&cookie.to_string(), "foo=bar; SameSite=None");
}
#[test]

5
codecov.yml Normal file
View File

@ -0,0 +1,5 @@
ignore: # ignore codecoverage on following paths
- "**/tests"
- "test-server"
- "**/benches"
- "**/examples"