Remove User-Agent header from REST API requests

Because some servers don't allow it by Access-Controll-Allow-Headers
This commit is contained in:
AkiraFukushima 2022-12-30 10:47:32 +09:00
parent 651b47de55
commit 55cc11c8d3
No known key found for this signature in database
GPG key ID: B6E51BAC4DE1A957
3 changed files with 17 additions and 102 deletions

View file

@ -78,12 +78,7 @@ namespace MastodonAPI {
): Promise<Response<T>> {
let options: AxiosRequestConfig = {
params: params,
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -128,12 +123,7 @@ namespace MastodonAPI {
*/
public async put<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -178,12 +168,7 @@ namespace MastodonAPI {
*/
public async putForm<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -228,12 +213,7 @@ namespace MastodonAPI {
*/
public async patch<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -278,12 +258,7 @@ namespace MastodonAPI {
*/
public async patchForm<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -328,12 +303,7 @@ namespace MastodonAPI {
*/
public async post<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -369,12 +339,7 @@ namespace MastodonAPI {
*/
public async postForm<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -411,12 +376,7 @@ namespace MastodonAPI {
public async del<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
data: params,
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}

View file

@ -470,12 +470,7 @@ namespace MisskeyAPI {
*/
public async post<T>(path: string, params: any = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}

View file

@ -303,12 +303,7 @@ namespace PleromaAPI {
public async get<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
params: params,
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
)
headers: headers
}
if (this.accessToken) {
options = objectAssignDeep({}, options, {
@ -351,12 +346,7 @@ namespace PleromaAPI {
*/
public async put<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -401,12 +391,7 @@ namespace PleromaAPI {
*/
public async putForm<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -451,12 +436,7 @@ namespace PleromaAPI {
*/
public async patch<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -501,12 +481,7 @@ namespace PleromaAPI {
*/
public async patchForm<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -551,12 +526,7 @@ namespace PleromaAPI {
*/
public async post<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -592,12 +562,7 @@ namespace PleromaAPI {
*/
public async postForm<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}
@ -634,12 +599,7 @@ namespace PleromaAPI {
public async del<T>(path: string, params = {}, headers: { [key: string]: string } = {}): Promise<Response<T>> {
let options: AxiosRequestConfig = {
data: params,
headers: Object.assign(
{
'User-Agent': this.userAgent
},
headers
),
headers: headers,
maxContentLength: Infinity,
maxBodyLength: Infinity
}