Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes

## 8.1.1 - Mar 14 2026

- Fix `CombinedStream` to throw `NotSupportedException` (instead of `Exception`) for unsupported operations (write, seek, set length); fixes a typo in the length error message
- Rename shadowed inner `isText` helper to `isMimeTypeText` for code clarity; add explanatory comment

## 8.1.0 - Mar 08 2026

- Add schema.org microdata support to `HtmlProvider`: when an HTML document contains elements with `itemscope`/`itemtype`/`itemprop` attributes, the provider now generates a typed `Schemas` container (e.g. `doc.Schemas.Person`) with one strongly-typed property per `itemprop` name discovered in the sample (closes #611)
Expand Down
30 changes: 22 additions & 8 deletions src/FSharp.Data.Http/Http.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,18 +1499,31 @@ module internal HttpHelpers =
override x.Length =
length
|> Option.defaultWith (fun () ->
failwith "One or more of the encompassed streams are not seekable and the length cannot be determine")
raise (
NotSupportedException(
"One or more of the encompassed streams are not seekable and the length cannot be determined"
)
))

override x.Position
with get () = v
and set (_) = failwith "no position setting"
and set (_) = raise (NotSupportedException("CombinedStream does not support seeking"))

override x.Flush() = ()
override x.CanTimeout = false
override x.Seek(_, _) = failwith "no seeking"
override x.SetLength(_) = failwith "no setting length"
override x.Write(_, _, _) = failwith "no writing"
override x.WriteByte(_) = failwith "seriously, no writing"

override x.Seek(_, _) =
raise (NotSupportedException("CombinedStream does not support seeking"))

override x.SetLength(_) =
raise (NotSupportedException("CombinedStream does not support setting length"))

override x.Write(_, _, _) =
raise (NotSupportedException("CombinedStream is read-only"))

override x.WriteByte(_) =
raise (NotSupportedException("CombinedStream is read-only"))

override x.Read(buffer, offset, count) = readFromStream buffer offset count

interface IDisposable with
Expand Down Expand Up @@ -1804,7 +1817,7 @@ module internal HttpHelpers =
async {

let isText (mimeType: string) =
let isText (mimeType: string) =
let isMimeTypeText (mimeType: string) =
let mimeType = mimeType.Trim()

mimeType.StartsWith("text/", StringComparison.Ordinal)
Expand All @@ -1819,8 +1832,9 @@ module internal HttpHelpers =
|| mimeType.StartsWith("application/", StringComparison.Ordinal)
&& mimeType.EndsWith("+json", StringComparison.Ordinal)

// Split on ';' to ignore MIME type parameters (e.g. "text/html; charset=utf-8")
mimeType.Split([| ';' |], StringSplitOptions.RemoveEmptyEntries)
|> Array.exists isText
|> Array.exists isMimeTypeText

let! memoryStream = asyncRead stream

Expand Down
4 changes: 2 additions & 2 deletions tests/FSharp.Data.Core.Tests/Http.fs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ let ``CombinedStream can seek with Some length`` () =
[<Test>]
let ``CombinedStream length throws with None length`` () =
use combinedStream = new HttpHelpers.CombinedStream(None, [])
(fun () -> combinedStream.Length |> ignore) |> should throw typeof<Exception>
(fun () -> combinedStream.Length |> ignore) |> should throw typeof<NotSupportedException>

[<Test>]
let ``CombinedStream cannot seek with None length`` () =
Expand All @@ -383,7 +383,7 @@ let ``Non-seekable streams create non-seekable CombinedStream`` () =
use nonSeekms = new nonSeekableStream(Array.zeroCreate 10)
let multiparts = [MultipartItem("","", nonSeekms)]
let combinedStream = HttpHelpers.writeMultipart "-" multiparts Encoding.UTF8
(fun () -> combinedStream.Length |> ignore) |> should throw typeof<Exception>
(fun () -> combinedStream.Length |> ignore) |> should throw typeof<NotSupportedException>
combinedStream.CanSeek |> should equal false

[<Test>]
Expand Down
Loading