Merge pull request #76 from Orange-OpenSource/fix/support-user-in-url

Support user in url
This commit is contained in:
Fabrice Reix 2020-11-10 07:43:49 +01:00 committed by GitHub
commit 401c8a9a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1 @@
<div class="hurl-file"><div class="hurl-entry"><div class="request"><span class="line"><span class="method">GET</span> <span class="string">http://bob:secret@localhost:8000/basic-authentication</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div></div>

View File

@ -0,0 +1,5 @@
GET http://bob:secret@localhost:8000/basic-authentication
HTTP/1.0 200
```You are authenticated```

View File

@ -0,0 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://bob:secret@localhost:8000/basic-authentication"},"response":{"version":"HTTP/1.0","status":200}}]}

View File

@ -0,0 +1,10 @@
from tests import app
from flask import request
@app.route('/user-in-url')
def user_in_url():
assert request.headers['Authorization'] == 'Basic Ym9iOnNlY3JldA=='
return 'You are authenticated'

View File

@ -444,6 +444,23 @@ fn test_basic_authentication() {
assert_eq!(response.status, 200);
assert_eq!(response.version, Version::Http10);
assert_eq!(response.body, b"You are authenticated".to_vec());
let mut client = default_client();
let request = Request {
method: Method::Get,
url: "http://bob:secret@localhost:8000/basic-authentication".to_string(),
headers: vec![],
querystring: vec![],
form: vec![],
multipart: vec![],
cookies: vec![],
body: vec![],
content_type: None,
};
let response = client.execute(&request, 0).unwrap();
assert_eq!(response.status, 200);
assert_eq!(response.version, Version::Http10);
assert_eq!(response.body, b"You are authenticated".to_vec());
}
// region error

View File

@ -195,7 +195,7 @@ fn url(reader: &mut Reader) -> ParseResult<'static, Template> {
None => break,
Some(c) => {
if c.is_alphanumeric()
|| vec![':', '/', '.', '-', '?', '=', '&', '_', '%', '*', ',']
|| vec![':', '/', '.', '-', '?', '=', '&', '_', '%', '*', ',', '@']
.contains(&c)
{
buffer.push(c);