You are not logged in.
Pages: 1
I am still trying to get any meaningful help on this wonderful resource....
How do i use THttpClientSocket when overring TSqlHttpServer.Request method to create a kind of proxy?
FClient := THttpClientSocket.Open('localhost', '8095');
result := FClient.Request(Ctxt.URL, Ctxt.Method, 10000, Ctxt.InHeaders, Ctxt.InContent, Ctxt.InContentType, TRUE);
Ctxt.OutContent := FClient.Content;
Ctxt.OutContentType := FClient.ContentType;
Ctxt.OutCustomHeaders := '';
for vIdx := Low(FClient.Headers) to High(FClient.Headers) do
Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10 + FClient.Headers[vIdx];
The end point services are RESTful services, i need to be able to handle GET/POST/DELETE etc
The code above works fine for small responses, but when it comes to lengthy datasets returns it seems the response data never gets through.
Should i somehow create a loop to add to Ctxt.OutContent or it should be handled in some other way?
Your headers are missing a #13#10 between the lines.
Is it what you mean? This does not work properly either...
Ctxt.OutCustomHeaders := '';
for vIdx := Low(vClient.Headers) to High(vClient.Headers) do
Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10 + vClient.Headers[vIdx];
Hello,
I am testing the framework for the purpose of creating a proxy server to a number of internal REST services.
I am overriding TSqlHttpServer.Request method with the following code
vURL := Ctxt.URL;
GetServiceConnectionPoint(vURL, vAddress, vPort);
vClient := THttpClientSocket.Open(vAddress, vPort);
try
result := vClient.Request(Ctxt.URL, Ctxt.Method, 5000, Ctxt.InHeaders, Ctxt.InContent, Ctxt.InContentType, TRUE);
Ctxt.OutContent := vClient.Content;
Ctxt.OutContentType := vClient.ContentType;
Ctxt.OutCustomHeaders := '';
for vIdx := Low(vClient.Headers) to High(vClient.Headers) do
Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + vClient.Headers[vIdx];
finally
vClient.free;
end;
This works fine for a number of scenarios like .Get and .Delete, but it does not return anything in .Content for some POST requests, while the end point does return the content.
Any advice, other than read the docs and samples (i did that already).
Thanx alot.
I can not find any references to THttpClientSocket, neither in documentation nor samples.
What is the proper flow of method calls?
Should i use .Open constructor to specify the IP and port of the server and then use .Get and pass auth?
I end up with 505 error and i now see this is being raised inside THttpClientSocket.Request method.
Hello,
I am using the following code to make a request and getting error 505
vBase64 := TBase64Encoding.Create;
try
vUsername := 'Dispatch';
vPassword := '1234';
vLogin := vUsername + ':' + vPassword;
vAuth := 'Authorization: Bearer ' + vBase64.Encode(vLogin);
finally
vBase64.Free
end;
FClient.Open('127.0.0.1', '8095', cslTCP, 0, FALSE);
//FClient.HeaderAdd(vAuth);
result := FClient.Get(vURL, 5000, vAuth);
With setup like this, do i get HTTP 1.1 request or do i need some other settings?
Thanx,
If you want to handle several /root1/... /root2/.. and so on, then TSQLHttpServer.Request is where to override.
This is exactly what i need and seems like i figured it out correctly.
I am using internal THttpClientSocket to communicate to end points. What is the proper flow of methods when working with it, should i call .Open first?
Basically i am trying to get the following code working in Request
result := FClient.Get(vURL);
Ctxt.OutContent := FClient.Content;
Ctxt.OutContentType := FClient.ContentType;
But this is for GET method, should i use similar structures for others?
When i connect to end point in browser it opens up auth dialog so i can supply username/password.
Are these being usually handled in PUT? Sorry this is not essentially a framework questions, but rather HTTP-related in general....
Thanx alot.
Why are you not using the default available authentication classes?
Because i have no idea about the framework yet and the classes it offers.
What classes should i use? Any sample code available?
Thanx.
I would rather combine the proxy at TSQLRestServer.URI level, not at HTTP level.
As i said i am completely new to the framework, so this says nothing to me actually...
Why would i better do it this way? What methods should i override etc?
Thanks.
I am new to this stuff and trying to pass login/password.
Should i do that before calling .Open?
vUsername := 'Dispatch';
vPassword := '1234';
vLogin := vUsername + ':' + vPassword;
vBase64 := TBase64Encoding.Create;
try
vAuth := 'Authorization: Basic ' + vBase64.Encode(vLogin);
finally
vBase64.Free
end;
FClient.HeaderAdd(vAuth);
FClient.Open('127.0.0.1', '8095');
result := FClient.Get(vURL);
Thanx alot.
Hello,
I am about to create a kind of proxy-service for a number of internal REST services, so this proxy would act as single entry point.
I determined i have to override TSQLHttpServer.Request method for that, is this approach feasible?
If so, i would need a client-side component to make a request to internal REST services and return the results to the caller.
Is there such a component in the framework? Any advice and sample code are greatly appreciated.
Thanx,
Eugene.
Okay, I have found 04 - HTTP Client-Server sample and I think this will get me started in correct direction.
Okay, so for "better design" I inherit from TSQLRestServerFullMemory then, right?
What method do I override to deal with URI and redirect based on certain keywords found?
Also can I avoid "root" and have it like http://localhost:888/id1 etc?
Thank you.
Is there any demos/sample code available?
I am studying the docs and determined it would make sense to use TSQLRestServerRemoteDB to create a proxy, but the docs do not give enough information to get into that stuff...
Thank you, I got it running.
Now when I hit it at http://127.0.0.1:888/root I get
{
"errorCode":400,
"errorText":"Bad Request"
}
Where do I put the server logic?
Basically what I want to do is, determine the URI part, like "root" or "id1" or "id2" etc, and based on that ID to pass the request to another URL.
How do I go about that?
Thanx once again!
I modified the sample code like this. I do not have TSQLServerFullMemory class in my installation it seems...
When I run this, I get Access is denied. I think this is something to do with permissions....
Hello,
I am new to this stuff and I am about to create a kind of proxy RESTful service with mORMot.
I saw some sample code and it always refers TSQLHttpServer component.
Is there a way I can create non-SQL server?
Any suggestions are greatly appreciated.
Thanx a lot.
Pages: 1