mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
fix content length
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions
This commit is contained in:
parent
35cc44faa3
commit
e407c1db19
|
@ -36,11 +36,12 @@ async function mihomoHttp<T>(method: HttpMethod, path: string, data?: object): P
|
||||||
)
|
)
|
||||||
client.on('data', function (res) {
|
client.on('data', function (res) {
|
||||||
try {
|
try {
|
||||||
const data = trimJson(res.toString().split('\r\n\r\n')[1])
|
const data = res.toString().split('\r\n\r\n')[1]
|
||||||
|
const json = trimJson(data)
|
||||||
if (res.toString().includes('HTTP/1.1 4') || res.toString().includes('HTTP/1.1 5')) {
|
if (res.toString().includes('HTTP/1.1 4') || res.toString().includes('HTTP/1.1 5')) {
|
||||||
reject(data ? JSON.parse(data) : undefined)
|
reject(json ? JSON.parse(json) : data)
|
||||||
} else {
|
} else {
|
||||||
resolve(data ? JSON.parse(data) : undefined)
|
resolve(json ? JSON.parse(json) : undefined)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(e)
|
reject(e)
|
||||||
|
@ -54,7 +55,7 @@ async function mihomoHttp<T>(method: HttpMethod, path: string, data?: object): P
|
||||||
if (data) {
|
if (data) {
|
||||||
const json = JSON.stringify(data)
|
const json = JSON.stringify(data)
|
||||||
client.write(
|
client.write(
|
||||||
`${method} ${path} HTTP/1.1\r\nHost: mihomo-party\r\nContent-Type: application/json\r\nContent-Length: ${json.length}\r\n\r\n${json}`
|
`${method} ${path} HTTP/1.1\r\nHost: mihomo-party\r\nContent-Type: application/json\r\nContent-Length: ${Buffer.from(json).length}\r\n\r\n${json}`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
client.write(`${method} ${path} HTTP/1.1\r\nHost: mihomo-party\r\n\r\n`)
|
client.write(`${method} ${path} HTTP/1.1\r\nHost: mihomo-party\r\n\r\n`)
|
||||||
|
@ -86,7 +87,7 @@ export const patchMihomoConfig = async (patch: Partial<IMihomoConfig>): Promise<
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mihomoCloseConnection = async (id: string): Promise<void> => {
|
export const mihomoCloseConnection = async (id: string): Promise<void> => {
|
||||||
return await mihomoHttp('DELETE', `/connection/${id}`)
|
return await mihomoHttp('DELETE', `/connections/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mihomoCloseAllConnections = async (): Promise<void> => {
|
export const mihomoCloseAllConnections = async (): Promise<void> => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user