Skip to content

Commit

Permalink
fix possible nullreferenceexception
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Jul 9, 2017
1 parent b655de5 commit 25f3129
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/Paket.Core/Common/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,24 @@ let getDefaultProxyFor =
type RequestFailedInfo =
{ StatusCode:HttpStatusCode
Content:Stream
MediaType:string
MediaType:string option
Url:string }
static member ofResponse (resp:HttpResponseMessage) = async {
let mem = new MemoryStream()
do! resp.Content.CopyToAsync(mem) |> Async.AwaitTaskWithoutAggregate
if not (isNull resp.Content) then
do! resp.Content.CopyToAsync(mem) |> Async.AwaitTaskWithoutAggregate
mem.Position <- 0L
//raise <| RequestReturnedError(resp.StatusCode, mem, resp.Content.Headers.ContentType.MediaType)
let mediaType =
resp.Content
|> Option.ofObj
|> Option.bind (fun c -> c.Headers |> Option.ofObj)
|> Option.bind (fun h -> h.ContentType |> Option.ofObj)
|> Option.bind (fun c -> c.MediaType |> Option.ofObj)
return
{ StatusCode = resp.StatusCode
Content = mem
MediaType = resp.Content.Headers.ContentType.MediaType
MediaType = mediaType
Url = resp.RequestMessage.RequestUri.ToString() } }
override x.ToString() =
sprintf "Request to '%s' failed with: '%A'" x.Url x.StatusCode
Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<StartProgram>paket.exe</StartProgram>
<StartAction>Project</StartAction>
<StartArguments>update</StartArguments>
<StartWorkingDirectory>C:\proj\Paket\integrationtests\scenarios\i001635-wrong-pw\temp</StartWorkingDirectory>
<StartWorkingDirectory>C:\proj\testing\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
Expand Down

0 comments on commit 25f3129

Please sign in to comment.