From 07330e78abd69530f63fef366ed630850f8577b2 Mon Sep 17 00:00:00 2001 From: Philip Tellis Date: Fri, 1 Apr 2022 12:32:37 -0400 Subject: [PATCH] Convert bytestream directly to String rather than one byte at a time so that we correctly handle UTF-8 characters --- Project.toml | 2 +- src/RepositoryAPI.jl | 4 ++-- src/exceptions.jl | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index acc027d..2694813 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "mPulseAPI" uuid = "314d2b54-f2c3-11ea-15f2-0bcf2fc50b35" authors = ["Akamai mPulse DSWB "] -version = "1.1.1" +version = "1.1.2" [deps] DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" diff --git a/src/RepositoryAPI.jl b/src/RepositoryAPI.jl index d79858f..f4a37ca 100644 --- a/src/RepositoryAPI.jl +++ b/src/RepositoryAPI.jl @@ -488,10 +488,10 @@ function getHttpRequest(token::AbstractString, objectType::AbstractString, searc throw(mPulseAPIException("Error fetching $(objectType) $(debugID)", resp)) end - json = join(map(Char, resp.body)) + json = String(resp.body) object = JSON.parse(json) - # If calling by a searchKey other than ID, the return value will be a Dict with a single key="objects" + # If calling by a searchKey other than ID, the return value will be a Dict with a single key="objects" # and value set to an array of domain objects. # If searching by ID, then the object is returned, so turn it into an array if haskey(object, "objects") && isa(object["objects"], Array) diff --git a/src/exceptions.jl b/src/exceptions.jl index 64cf646..0ee0a92 100644 --- a/src/exceptions.jl +++ b/src/exceptions.jl @@ -24,7 +24,7 @@ struct mPulseAPIException <: Exception response::HTTP.Response responseBody::AbstractString - mPulseAPIException(msg::AbstractString, response::HTTP.Response) = new(msg, response, join(map(Char, response.body))) + mPulseAPIException(msg::AbstractString, response::HTTP.Response) = new(msg, response, String(response.body)) end """ @@ -46,7 +46,7 @@ struct mPulseAPIAuthException <: Exception response::HTTP.Response responseBody::AbstractString - mPulseAPIAuthException(response::HTTP.Response) = new("Error Authenticating with REST API", response, join(map(Char, response.body))) + mPulseAPIAuthException(response::HTTP.Response) = new("Error Authenticating with REST API", response, String(response.body)) end """ @@ -112,5 +112,5 @@ struct mPulseAPIBugException <: Exception response::HTTP.Response responseBody::AbstractString - mPulseAPIBugException(resp::HTTP.Response) = new("Internal Server Error, please report this. Timestamp: $(round(Int, datetime2unix(now())))", resp, join(map(Char, resp.body))) + mPulseAPIBugException(resp::HTTP.Response) = new("Internal Server Error, please report this. Timestamp: $(round(Int, datetime2unix(now())))", resp, String(resp.body)) end