varamfer / openhab

Automatically exported from code.google.com/p/openhab
0 stars 0 forks source link

Add possibility to provide HTTP headers for the HTTPBinding #153

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. Feature Description
For getting data from FLUKSO sensors I need to provide HTTP header during HTTP 
GET method execution. Is it possible to add optional headers for HTTP binding 
URL in form header1=value1&header2=value2 
The best part I think to put it after URL in the HTTPBinding string.
So format of HTTPBinding could be something like:
http="<[url:header1=value1&header2=value2:refreshinterval:transformation-rule]"

2. Example Use Case
http="<[https://www.flukso.net/api/sensor/xxxx?interval=daily:X-Token=mytoken&X-
version=1.0:60000:REGEX(.*?<title>(.*?)</title>(.*))]"

Original issue reported on code.google.com by ramazany...@gmail.com on 21 Nov 2012 at 10:32

GoogleCodeExporter commented 8 years ago
Hi Thomas, what do you think about this? Might be useful, we just have to be 
careful that the syntax does not get too bloated.

Original comment by kai.openhab on 22 Nov 2012 at 9:10

GoogleCodeExporter commented 8 years ago

Original comment by teichsta on 22 Nov 2012 at 9:47

GoogleCodeExporter commented 8 years ago
Actually I see that ':' character is used for pattern matching and to do not 
interfere with already existing implementation I would suggest slightly 
different format of binding config string:
http="<[url{header1=value1&header2=value2}:refreshinterval:transformation-rule]"

example:
http="<[https://www.flukso.net/api/sensor/xxxx?interval=daily{X-Token=mytoken&X-
version=1.0}:60000:REGEX(.*?<title>(.*?)</title>(.*))]"

headers are put between {} in the url part and actually it should be optional 
to add {headers} part, so old syntax still should work.
I will give it a try and commit it in clone of openhab project once it is ready

Original comment by ramazany...@gmail.com on 9 Dec 2012 at 12:18

GoogleCodeExporter commented 8 years ago
I made changes to the source in my cloned repository named 
ramazanyich-httpbinding-headers.
The change is rather small. I also added necessary unit tests to new format.
Could you please review it and add to the main project source?
Thanks in advance.

Original comment by ramazany...@gmail.com on 9 Dec 2012 at 10:16

GoogleCodeExporter commented 8 years ago
merged enhancement to default branch (see 
http://code.google.com/p/openhab/source/detail?r=2e5a6323c475feeb9ab0fe5dc52bef1
20e149780)

Original comment by teichsta on 16 Dec 2012 at 3:38

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Please update wiki for the HTTP binding.
Add section: 
'HTTP headers in the binding.
Both OutBinding  and InBinding has possibility to define optional HTTP headers 
which will be sent during HTTP method call. Those optional headers could be 
added to the url in form header1=value1&header2=value2.... This headers string 
should be enclosed into curly brackets right after the url itself (before 
separation colon).
Example: 
http="<[https://www.flukso.net/api/sensor/xxxx?interval=daily{X-Token=mytoken&X-
version=1.0}:60000:REGEX(.*?<title>(.*?)</title>(.*))]"
'

Original comment by ramazany...@gmail.com on 17 Dec 2012 at 7:57

GoogleCodeExporter commented 8 years ago
Thanks, I have updated the wiki page accordingly.

Original comment by kai.openhab on 17 Dec 2012 at 10:17