Skip to content
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

[HTTP] Feature Request - Off Cycle Refresh & Agent String #9265

Closed
morph166955 opened this issue Dec 6, 2020 · 9 comments
Closed

[HTTP] Feature Request - Off Cycle Refresh & Agent String #9265

morph166955 opened this issue Dec 6, 2020 · 9 comments
Labels
enhancement An enhancement or new feature for an existing add-on

Comments

@morph166955
Copy link
Contributor

Requesting two features be added to the HTTP binding:

  1. Ability to trigger an off cycle refresh. Some devices do not work well getting flooded with API requests so dialing the refresh down is not necessarily desirable. Example usage: Assume we send a power on/off command to a device via the binding moments after a scheduled update. There will be an obvious want to update the channels more frequently than the standard refresh. An action for the thing could likely do this as part of a rule. For example:

rule "TV Power Change"
when
Item TVPower received command
then
val httpActions = getActions("http","http:url:mytv")
httpActions.forceRefresh()
end

  1. Some APIs require specific agent strings to be set for functionality. If this could be set as part of the Thing it would enable this. Similar in function to "curl -A"
@morph166955 morph166955 added the enhancement An enhancement or new feature for an existing add-on label Dec 6, 2020
@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/change-user-agent-in-http-binding/121142/7

@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/sendhttpgetrequest-does-not-respect-user-agent-in-header/144838/2

@jlaur
Copy link
Contributor

jlaur commented Feb 28, 2023

I recently experienced that when setting the user-agent in a HTTP header, Jetty will use two user-agents (the one set and its own), which is considered an error by some web servers. For example, energidataservice.dk failed. The fix was to set it using the agent method: https:/openhab/openhab-addons/pull/14376/files#diff-a299a861229ecc8972ed87af778fbfe04ad31a424ec3f294ef7bdc91682ea335R116

However, after this change and inspecting my web server logs in my emulated environment, I saw the same thing happening after a redirect, i.e.:

https://host/path
-> one agent

redirect to:
https://host/path/
-> now two agents

@J-N-K
Copy link
Member

J-N-K commented Feb 28, 2023

See smarthomej/addons#77

@jimtng
Copy link
Contributor

jimtng commented Feb 28, 2023

@jlaur could you help test this https://community.openhab.org/t/sendhttpgetrequest-does-not-respect-user-agent-in-header/144838/3

I haven't tested whether it affects/fixes the http binding. I did test it on the HTTP action HTTP.sendHttpGetRequest.

The easiest way to check is by making a request to https://httpbin.org/headers - it will return the request headers in its HTTP response body - with an extra field X-Amzn-Trace-Id

@jlaur
Copy link
Contributor

jlaur commented Mar 1, 2023

@jimtng - what do you specifically need tested? I'm not currently using the HTTP binding, so I'm not sure if you tagged me by mistake?

@jimtng
Copy link
Contributor

jimtng commented Mar 1, 2023

@jimtng - what do you specifically need tested? I'm not currently using the HTTP binding, so I'm not sure if you tagged me by mistake?

oops sorry, yes it was a mistake.

@jimtng
Copy link
Contributor

jimtng commented Mar 1, 2023

@morph166955

  1. Ability to trigger an off cycle refresh. Some devices do not work well getting flooded with API requests so dialing the refresh down is not necessarily desirable. Example usage: Assume we send a power on/off command to a device via the binding moments after a scheduled update. There will be an obvious want to update the channels more frequently than the standard refresh. An action for the thing could likely do this as part of a rule. For example:

This can be done by sending a REFRESH command to the relevant Item.

2. Some APIs require specific agent strings to be set for functionality. If this could be set as part of the Thing it would enable this. Similar in function to "curl -A"

Added in #14518

@lsiepel
Copy link
Contributor

lsiepel commented Jan 14, 2024

Fixed by: #16282

@lsiepel lsiepel closed this as completed Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
6 participants