#1 2013-10-29 12:55:46

chapa
Member
Registered: 2012-04-30
Posts: 117

ModelRoot/TableName/ID/MethodName

Hi ab,

It is very handy to call Method based services and have TSQLRecordClass and record id in the TSQLRestServerCallBackParams context.

Is it possible to implement something like "ModelRoot/TableName/MethodName" ?
This will complement the use cases where method should be called against the whole table, without the need to specify it in additional url parameters.

Offline

#2 2013-10-29 13:31:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: ModelRoot/TableName/ID/MethodName

AFAIK default RESTful implementation in the new TSQLRestServerURIContext class expects an URI encoded with 'ModelRoot/MethodName' or 'ModelRoot/TableName[/ID]/MethodName' formats.

Then you can use Table/TableIndex/TableRecordProps/TableEngine properties for direct access to the specified /TableName

Offline

#3 2013-10-29 13:58:30

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: ModelRoot/TableName/ID/MethodName

right, it works with latest sources (after BREAKING CHANGE)
thanks.

Offline

#4 2013-10-29 14:51:53

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: ModelRoot/TableName/ID/MethodName

ab, after updating the source with the new TSQLRestServerURIContext I got following:

20131029 16374619  " EXCOS EAccessViolation (C0000005) at 001CF809 mORMot.TSQLRestRoutingREST.URIDecodeSOAByInterface (24348)  stack trace API 001865C4 SynCommons.SynRtlUnwind (31512) 0000945C System.@HandleOnException
i := Server.Services.fListInterfaceMethod.IndexOf(URI); -> here Server.Services are nil

This happen every time when trying to call invalid (non-existing) method name of the rest server (and no interface services defined).
Maybe some handled error will be more suitable than showing AV exception with debug information to the client.

Also I was unable to get compression working.
Defined in the project COMPRESSDEFLATE, also tried to manually RegisterCompress, but with no luck.
Browser request compression, but the server never compress (tried also with big json as response).

Last edited by chapa (2013-10-29 14:54:46)

Offline

#5 2013-10-29 16:44:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: ModelRoot/TableName/ID/MethodName

I've fixed the unexpected GPF.
It was indeed a regression due to the new class-driven implementation.
See http://synopse.info/fossil/info/0171854e68
and http://synopse.info/fossil/info/8acac4fc09
Thanks for the report.

For the compression, which browser are you using?

Offline

#6 2013-10-29 16:50:46

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: ModelRoot/TableName/ID/MethodName

thank.
using latest firefox and chrome.
right headers sent, but response is not compressed.

Offline

#7 2013-10-30 13:00:29

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: ModelRoot/TableName/ID/MethodName

I believe it is some protocol handler on my win box.
Tried to disable the antivirus, but no luck, same problem.

Some protocol handler seem to decompress on the fly the http compressed response content and serve it uncompressed skipping Content-Encoding: deflate header from the http response.
If someone know how I can list/trace all protocol handlers in order to catch who is doing this will help a lot.
Thanks.

Offline

#8 2013-10-30 13:48:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: ModelRoot/TableName/ID/MethodName

AFAIK in chrome, you can see the headers and the size in debugger mode.

Offline

#9 2013-10-30 15:41:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: ModelRoot/TableName/ID/MethodName

I just checked with the sample program HttpApiServer - and found no problem with Chrome: the content is encoded with "deflate".

Which server class are you using?
The Socket-based or the HTTP.SYS-based?

What is the content type of the returned data?
We only compress 1KB of TEXT/ or APPLICATION/XML or APPLICATION/JSON kind of data.

Please ensure your server does execute the function CompressDataAndGetHeaders().
Use the debugger to see what's wrong.

Offline

#10 2013-10-30 16:43:27

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: ModelRoot/TableName/ID/MethodName

I confirm - there is no problem with compression. I use gzip. Last version of Chrome and Firefox - all content > 1Kb gzipped successfully. If you not sure your browser plugins do uncompression or not - use http://fiddler2.com/ as a proxy and see there.

Last edited by mpv (2013-10-30 16:46:50)

Offline

#11 2013-10-30 16:47:48

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: ModelRoot/TableName/ID/MethodName

1. HTTP.SYS one.
2. application/json
3. debugged and ensured it returns compressed content and size

Chrome, Firefox even command line wget.exe returns uncompressed data (wget with Accept-Encode headers set). Tried connecting from localhost to: 1.localhost (for debugging) and 2. remote server (production).
But ... when accessing my computer and production server from other machines, data is compressed smile ...

This leads my mind, that some antivirus or other http protocol handler on localhost catches the response and manipulate it.

Offline

#12 2013-10-30 16:57:00

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: ModelRoot/TableName/ID/MethodName

Hm.. If in fiddler you also don't see compression headers try http://www.wireshark.org/ - I use sometimes this tool to analyze network on low level.

Offline

#13 2013-10-30 17:05:42

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: ModelRoot/TableName/ID/MethodName

Forgot to mention, fiddler also tried, no Content-Encoding header in the response, body is decompressed.
Fiddler is a proxy, they use .NET classes to access Inet, AFAIK.

Once I used to write protocol handlers. Before response hit the client it can be manipulated by several handlers. So I guess it is something like that sitting between the client and actual response.
For protocol handler point of view it does not mind who the client is.

Will give a try to wireshark tomorrow and let you know.

Last edited by chapa (2013-10-30 17:06:59)

Offline

#14 2013-10-30 17:16:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: ModelRoot/TableName/ID/MethodName

chapa wrote:

debugged and ensured it returns compressed content and size

Chrome, Firefox even command line wget.exe returns uncompressed data (wget with Accept-Encode headers set). Tried connecting from localhost to: 1.localhost (for debugging) and 2. remote server (production).
But ... when accessing my computer and production server from other machines, data is compressed smile ...

This leads my mind, that some antivirus or other http protocol handler on localhost catches the response and manipulate it.

So... data is compressed!
smile

Offline

Board footer

Powered by FluxBB