NetTalk Central

Author Topic: What is the HTTP OPTIONS method?  (Read 7573 times)

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
What is the HTTP OPTIONS method?
« on: October 05, 2013, 01:09:52 AM »
I have one commercial JS library and tried to activate some options from Nettalk with Ajax function. I sent request to Nettalk with HTTP OPTIONS and I was totally confused. I googled a little and found this:

http://zacstewart.com/2012/04/14/http-options-method.html

I learned that this is valid HTTP request so I think that NetTalk should support this.

Best regards,

Djordje Radovanovic

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: What is the HTTP OPTIONS method?
« Reply #1 on: October 06, 2013, 03:25:46 PM »
Hi Djordje,

When I have to talk to webservices I often need more than Get and Post, some HTTP protocols are used as verbs when sharing data. I think the follow protocols would be good to support, even though in day-to-day operation its rare to use most of these.

Options
Get
Head
Post
Put
Delete
Trace
Connect
Patch

I've had to hack my NetTalk to support them. So I could talk to webservices like google.

Regards
Bill

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #2 on: October 06, 2013, 03:50:26 PM »
Bill,

Thanks for your comment. It proves me that I am not the only one who notice this.
Unfortunately I am not as advanced user as you are and I am not sure that I could tweak my templates to support this. And logically there is a question of regular template updates to implement all this changes in a new release, so I believe (but I am not sure) that this is not so big effort to support this and obviously we are not the only who will need this in a following months.

Best regards,

Djordje Radovanovic




bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: What is the HTTP OPTIONS method?
« Reply #3 on: October 06, 2013, 07:33:01 PM »
Hi Djordje,

You are correct. I hacked the template to make sure I was doing it right. To see if I could get the webservice stuff to work.

It was mentioned in this post:

http://www.nettalkcentral.com/index.php?option=com_smf&Itemid=36&topic=3787.0

Regards
Bill

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #4 on: October 06, 2013, 10:36:33 PM »
Hi Djordje,

>> I have one commercial JS library and tried to activate some options from Nettalk with Ajax function. I sent request to Nettalk with HTTP OPTIONS and I was totally confused.

can you tell me more about this part please. Specifically I'm interested in what the OPTIONS call was used for?
And more importantly I suppose, what it was expecting to receive in return.

cheers
Bruce

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: What is the HTTP OPTIONS method?
« Reply #5 on: October 06, 2013, 10:57:31 PM »
Hi Bruce,

I don't mean to hjjack Djordje's thread, just thought I'd list some info on the other HTTP verbs that i've bumped into during my travels:

CalDAV - https://code.google.com/p/sabredav/wiki/BuildingACalDAVClient

PROPFIND, PROPPATCH, REPORT, MKCOL, MKCALENDAR, ACL.

Google Drive API - https://developers.google.com/drive/v2/reference/

PATCH

Regards
Bill

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #6 on: October 07, 2013, 04:40:41 AM »
Hi Bruce,

I found this request when I tried to activate Grid in Syncfusion Esential Studio for JavaScript. It is still in beta version and it is free to download.
Code that send me this request with OPTIONS looks like this and it is looking for some JSon Data.

<div id="Grid"></div>
    <script type="text/javascript">
        $(function () {
            var dataManger = ej.DataManager({
                url: "http://127.0.0.1:88/Request"
            });
            $("#Grid").ejGrid({
                dataSource: dataManger,
                allowPaging: true,
                pageSettings: { pageSize: 9 },
                columns: [
                                            { field: "PrezimeIme", headerText: "Prezime Ime", key: true, width: 75, isIdentity: true, textAlign: ej.textAlign.Right },
                                            { field: "MBroj", headerText: "Matični broj", width: 90 }
                ]
            });
        })
    </script>

I believe that this is enough information.

Best regards,

Djordje Radovanovic

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #7 on: October 09, 2013, 12:06:43 AM »
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

This might be helpful also.

Best regards,

Djordje Radovanovic

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #8 on: October 17, 2013, 02:33:19 AM »
Any info about subject?

Best regards,

Djole

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #9 on: October 17, 2013, 05:01:25 AM »
no information at this point. I'm looking into it, but for security reasons this isn't a part of the system I like to rush.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #10 on: October 27, 2013, 11:46:31 PM »
Hi Djordje,

In 7.28 I have added a new method to the server, called SetRequestMethodType. This is called when an incoming packet is first recived to determine the "Verb" of the packet. Supported (recognized) verbs are

GET, HEAD, OPTIONS, POST, PUT, DELETE, PROPFIND, FIND, PROPPATCH, PATCH, REPORT, TRACE, CONNECT

A person could extend this method to accept more Verbs if you wanted to.

So in your code you can test p_web.RequestMethodType - which will be one of

NetWebServer_POST                     equate(1)
NetWebServer_GET                      equate(2)
NetWebServer_PUT                      equate(3)
NetWebServer_DELETE                   equate(4)
NetWebServer_HEAD                     equate(5)
NetWebServer_OPTIONS                  equate(6)
NetWebServer_TRACE                    equate(7)
NetWebServer_CONNECT                  equate(8)
NetWebServer_PATCH                    equate(9)
NetWebServer_REPORT                   equate(10)
NetWebServer_FIND                     equate(11)


GET, DELETE, HEAD, POST and PUT are handled "automatically". For the other verbs you need to decide how you want them to be processed. there is a (new) method called ProcessVerb which allows you to customize how each Verb will be processed.

I _suspect_ that in many cases you will process "as if it was a get" - but returning a different value for differnet verbs. For example, you want to handle OPTIONS. In your case the URL is almost certainly pointing to a NetWebPage - which in turn you could add code to to send back something when it gets the OPTIONS verb. So in WebHandler, in ProcessVerb, you might have

case Self.RequestMethodType
of NetWebServer_OPTIONS
    self._HandleGet()
    if self.AllDone then return.
    self._HandleGetRest()
End


Hopefully this is enough for you to keep going.

Cheers
Bruce




Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #11 on: October 30, 2013, 09:17:28 AM »
Thanks Bruce,

I will try to implement this new feature.

Best regards,

Djordje Radovanovic

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #12 on: October 31, 2013, 04:10:37 AM »
Bruce,

SELF.RequestMethodType is always set to zero (0). Maybe I do something wrong?

Best regards,

Djordje Radovanovic

Djordje Radovanovic

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Re: What is the HTTP OPTIONS method?
« Reply #13 on: October 31, 2013, 04:31:31 AM »
Bruce, I think I found problem.

It is 272 line in NetWeb.clw file

        space1 = instring(' ',self._ConnectionDataQueue.Data,1,1)
        if space1 > 0 and space1 < 8                       ************** This is 272 line ************
          ! Check binData
          self._ConnectionDataQueue.RequestMethodType = self.SetRequestMethodType(upper(self._ConnectionDataQueue.Data[1 :    space1]))

String in self._ConnectionDataQueue.Data look for ex. OPTIONS /Request where ' ' (blank) is in 8th position so it coud not be true for OPTIONS.

Best regards,

Djordje Radovanovic