Jump to content




Set HTTP request properties


10 replies to this topic

#1 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 21 November 2012 - 06:15 PM

Suggestion: Include the ability to set request properties for http.request()

http.request( url, postData, ... )
where '...' can be strings, each defining a property, like e.g.:
http.request( "http://www.example.com/index.php", "var1=foo&var2=bar", "User-Agent: Mozilla/5.0", "Content-Type: image/jpeg")

This would allow one to change e.g. the default Java User-Agent to a customized one.
Without this ability, certain websites are not accessible due to blocking requests with unsupported User-Agent strings, as discussed here:
http not working for google search

#2 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

Posted 21 November 2012 - 08:46 PM

I love this idea! It should be added since there is no obvious security holes like other suggestions.

#3 TehSomeLuigi

  • Members
  • 70 posts

Posted 26 November 2012 - 12:04 AM

Also, : COOKIE SUPPORT.
Yes, I really want cookies.

#4 Left4Cake

  • Members
  • 272 posts
  • LocationEarth

Posted 12 December 2012 - 11:06 AM

I second Cookie Support, I tried to use Sessions for something but then learned that Sessions also require Cookies.

#5 AfterLifeLochie

    Wiki Oracle

  • Moderators
  • 480 posts
  • LocationAfterLifeLochie's "Dungeon", Australia

Posted 14 December 2012 - 08:36 PM

I think this is definitely a good idea.

If this doesn't get added (or considered), I suppose I or someone can pick it up as a peripheral - although I'd have no idea as to what I'm doing, as I haven't actually done any really serious modding. No better time to learn, I suppose!

#6 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 14 December 2012 - 10:51 PM

I'll look into it :-)

#7 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 12 April 2013 - 05:45 AM

Hey Cloudy, did you by any chance have the opportunity to take a look at it yet?
Being able to build a custom header per request would greatly extend the ability of POST requests.
Just curious and wanted to refresh your memory in case you forgot about it, no pressure.
Though I'd highly appreciate it of course. ^_^

#8 zekesonxx

  • Signature Abuser
  • 263 posts
  • LocationWhere you aren't

Posted 12 April 2013 - 07:19 AM

You don't need to code in cookie support Cloudy. Just put in header support, cookies are just headers after all.

#9 Xfel

    Peripheral Designer

  • Members
  • 515 posts

Posted 12 April 2013 - 11:27 PM

I think the problem is: If you it call like
http.post("<someaddress>", { xy="Hello World!" } )
they would need to pass a TABLE as argument to a JAVA METHOD. And for some reason they don't want to implement it.

#10 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 12 April 2013 - 11:59 PM

View PostXfel, on 12 April 2013 - 11:27 PM, said:

I think the problem is: If you it call like
http.post("<someaddress>", { xy="Hello World!" } )
they would need to pass a TABLE as argument to a JAVA METHOD. And for some reason they don't want to implement it.

It is planned, we've just not done it yet.

#11 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 13 April 2013 - 04:08 AM

View PostXfel, on 12 April 2013 - 11:27 PM, said:

I think the problem is: If you it call like
http.post("<someaddress>", { xy="Hello World!" } )
they would need to pass a TABLE as argument to a JAVA METHOD. And for some reason they don't want to implement it.

But we don't necessarily need to pass the header properties as a table. Shouldn't it be possible to provide the header properties as a sequence of arguments rather than an array/table? Like so:
http.post("<someaddress>", "<post data>", "<header property 1>", "<header property 2>", "<header property 3>" )

Then, Java-side, we simply look if there are more than two arguments, and if there are, we iterate through them and set the HTTP header properties as given.
I mean, isn't that basically what we can even do with the peripheral API already? I.e. to read a sequence of Lua arguments into a Java Object array?
I haven't looked at the code for the HTTP API yet, so I don't know if it is handled differently there than the peripheral API does.^^

View PostCloudy, on 12 April 2013 - 11:59 PM, said:

It is planned, we've just not done it yet.
That's nice to know, thx for the info. :)

Edited by Espen, 13 April 2013 - 04:09 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users