NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Djordje Radovanovic 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
-
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
-
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
-
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
-
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
-
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
-
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
-
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
This might be helpful also.
Best regards,
Djordje Radovanovic
-
Any info about subject?
Best regards,
Djole
-
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.
-
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
-
Thanks Bruce,
I will try to implement this new feature.
Best regards,
Djordje Radovanovic
-
Bruce,
SELF.RequestMethodType is always set to zero (0). Maybe I do something wrong?
Best regards,
Djordje Radovanovic
-
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