Thanks to visit codestin.com
Credit goes to github.com

Skip to content

implement http content-negotiation for plotly-graph #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2019

Conversation

antoinerg
Copy link
Collaborator

@antoinerg antoinerg commented Apr 15, 2019

Closes #226

Check added tests for details!

  • Return default format when HTTP accept: */* and accept: *

})
})

t.test('it should override format provided in payload', t => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one... 🤔

Problematic case: the user asks for SVG in HTTP header but also ask for PNG in the payload via format attribute. Which one should win?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have it the right way here: header overriding payload.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard I decided to go with payload overriding HTTP header in 9d74f00

The reason is that I don't want to introduce a breaking change in the HTTP API. So for users that defines the format in their payload, Orca should behave the same way.

@@ -157,7 +157,7 @@ function createServer (app, BrowserWindow, ipcMain, opts) {
}

pending++
comp._module.parse(body, compOpts, sendToRenderer)
comp._module.parse(body, compOpts, sendToRenderer, req)
Copy link
Contributor

@etpinard etpinard Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I would prefer leaving sendToRenderer as the last argument, as callbacks sendToRenderer are usually passed last.

I think having

 comp._module.parse(body, req, compOpts, sendToRenderer)

would be best ... and don't forget to update:

https://github.com/plotly/orca/blob/master/CONTRIBUTING.md#nomenclature-for-ipc-callbacks

accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in c1e0ab5

@@ -2,7 +2,7 @@

const path = require('path')
const { spawn } = require('child_process')
const electronPath = require('electron')
const electronPath = process.env['ELECTRON_PATH'] ? process.env['ELECTRON_PATH'] : require('electron')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Copy link
Collaborator Author

@antoinerg antoinerg Apr 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not mandatory for this PR but it provides a way to use a manually installed electron in the event that electron-download fails to install pre-built binary for your platform.

I could remove it but it's a must-have in my current dev environment and maybe it is also the case for others. It simply gives more flexibility. What do you think?

@etpinard etpinard added this to the v1.3 milestone Apr 17, 2019
@@ -184,6 +184,34 @@ tap.test('createServer:', t => {
})
})

t.test('it should do HTTP content-negotation for *plotly-graph* component', t => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to your other content-negotiation tests? Don't you want to test a valid content negotiation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the oversight! Thank you so much for the spotting this @etpinard. Removing the tests in my previous commit was a mistake.

Fixed in a95efcf

@etpinard
Copy link
Contributor

Nicely done 💃

@antoinerg antoinerg merged commit 4fc6d3a into master Apr 17, 2019
@antoinerg antoinerg deleted the http-content-negotiation branch April 17, 2019 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for HTTP "Content negotiation"
2 participants