Skip to content

Add Content-Type header to HTTP responses for JSON data.#30

Closed
benmkent wants to merge 7 commits intoUM-Bridge:mainfrom
benmkent:html-explicit-json
Closed

Add Content-Type header to HTTP responses for JSON data.#30
benmkent wants to merge 7 commits intoUM-Bridge:mainfrom
benmkent:html-explicit-json

Conversation

@benmkent
Copy link
Copy Markdown

Adds explicit JSON type to HTTP responses to address #23 .

To achieve this, successful responses must be explicitly given the HTTP status code 200.

@benmkent
Copy link
Copy Markdown
Author

@thealanjason I created a new branch as in my fork the other pieces are a bit tangled up. This is should update all the HTTP responses to explicitly specify the content type is JSON, and MATLAB will understand the responses.

@thealanjason
Copy link
Copy Markdown
Collaborator

Hi @benmkent

thanks for creating a new PR!

Could you please:

  1. add the Content-Type to all the HTTP requests as well. For example: update https://github.com/benmkent/UMBridge.jl/blob/5215be52db6b424b5cc191a4459cd15f4c43e770/src/UMBridge.jl#L37 to response = HTTP.request("POST", url(model) * "/Evaluate", ["Content-Type"=>"application/json"], body=JSON.json(body))
  2. bump the version number to "1.1.8" in the Project.toml

I've added a separate issue to add tests to check for the "Content-Type" in the header, which can be worked upon later when this is uniformly implemented for all languages that UMBridge supports.

@benmkent benmkent marked this pull request as draft September 19, 2025 10:59
@benmkent
Copy link
Copy Markdown
Author

I have messed up the branch and I have not got time to fix this at the moment due to starting a new position on Monday, I will address this in the future.

It might be possible to fix the JSON issues directly from the MATLAB side, in line 19-24 of the HTTPModel class. I believe this is where MATLAB gets confused about the content type using the "send" function.

@benmkent benmkent closed this Sep 19, 2025
@benmkent benmkent deleted the html-explicit-json branch September 19, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants