-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
102 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default (req, res) => { | ||
const reqValue = (new URLSearchParams(req.headers.cookie || '').get('mycookie') || '').split(';')[0].trim() | ||
const newValue = Math.round(Math.random() * 1000) + '' | ||
res.setHeader('Set-Cookie', `mycookie=${newValue}; path=/`) | ||
res.end(JSON.stringify([reqValue, newValue], null, 2)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default async (req, res) => { | ||
const query = new URL(req.url, 'http://localhost:3000').query | ||
if (query && query.delay) { | ||
await sleep(query.delay) | ||
} | ||
|
||
res.end(JSON.stringify({ | ||
url: req.url, | ||
method: req.method | ||
})) | ||
} | ||
|
||
function sleep (ms) { | ||
return new Promise((resolve) => { | ||
setTimeout(resolve, ms) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
<template> | ||
<div> | ||
there should be no loading bar left over: | ||
<button @click="test">Fake Request</button> | ||
<button @click="test"> | ||
Fake Request | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
methods: { | ||
test() { | ||
const source = this.$axios.CancelToken.source(); | ||
test () { | ||
const source = this.$axios.CancelToken.source() | ||
this.$axios | ||
.$post( | ||
"http://localhost:3000/test_api/foo/bar?delay=1000", | ||
{ data: "test" }, | ||
'http://localhost:3000/api/test/foo/bar?delay=1000', | ||
{ data: 'test' }, | ||
{ | ||
cancelToken: source.token, | ||
cancelToken: source.token | ||
} | ||
) | ||
.catch((err) => { | ||
if (this.$axios.isCancel(err)) { | ||
console.log("request canceled"); | ||
console.log('request canceled') | ||
} | ||
}); | ||
}) | ||
setTimeout(function () { | ||
source.cancel(); | ||
}, 500); | ||
}, | ||
}, | ||
}; | ||
source.cancel() | ||
}, 500) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template> | ||
<div> | ||
<p>Client proxy pass: {{ proxyWorks }}</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data () { | ||
return { | ||
proxyWorks: '?' | ||
} | ||
}, | ||
async mounted () { | ||
this.clientCookie = new URLSearchParams(document.cookie).get('mycookie') | ||
const a = await this.$axios.$get('/cookie') | ||
const b = await this.$axios.$get('/cookie') | ||
this.proxyWorks = a[1] === b[0] | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<template> | ||
<div> | ||
<p>SSRCookie: {{ ssrCookie }}</p> | ||
<p>ClientCookie: {{ clientCookie }}</p> | ||
<p>SSR proxy pass: {{ clientCookie === ssrCookie }}</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
async asyncData ({ app }) { | ||
const [_, ssrCookie] = await app.$axios.$get('/cookie') | ||
return { | ||
ssrCookie | ||
} | ||
}, | ||
data () { | ||
return { | ||
clientCookie: '' | ||
} | ||
}, | ||
mounted () { | ||
this.clientCookie = new URLSearchParams(document.cookie).get('mycookie') | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters