我尝试将标头值为large = pd.Series([random.choice(string.ascii_uppercase) +
random.choice(string.ascii_uppercase)
for _ in range(100000)])
In [275]: %timeit [x.lower() if pd.notnull(x) else x for x in large]
73.3 ms ± 4.24 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [276]: %timeit large.str.lower()
28.2 ms ± 684 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
In [277]: %timeit [x.lower() for x in large]
14.1 ms ± 784 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
的请求发送到我的REST API。我尝试通过以下代码实现这一点
Conent-type
它工作正常,并且在Chrome开发者工具的“请求标头”部分下,我的请求带有 getTokenizedLoginStatus(user: User): Observable<any> {
httpOptions = {
headers: new HttpHeaders({'Content-type': 'text/plain'})
};
return this.http.post<any>(apiUrl + '/archive/users/tokenizedLogin', user, httpOptions);
}
标头。但是,现在我想在请求中发送多个标头,如下图所示
Content-type: text/plain
当我发出请求时,Content-Type标头值不再存在,并且出现错误提示。
getTokenizedLoginStatus(user: User): Observable<any> {
httpOptions = {
headers: new HttpHeaders({'Content-type': 'text/plain', 'User': 'someone', 'Token': '123456'})
};
return this.http.post<any>(apiUrl + '/archive/users/tokenizedLogin', user, httpOptions);
}
但是在我的Java代码中,我定义了Access-Control-Allow-Origin如下:
Failed to load
http://localhost:8080/DemoProject/archive/users/tokenizedLogin:
Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:4200' is therefore not allowed
access.
我不明白为什么Content-Type不再作为请求的一部分发送,或者为什么我的API抛出该错误。以及如何修改我的代码以同时发送所有这些标头?