Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 04 21:35
    lganzzzo commented #443
  • Aug 04 21:32

    lganzzzo on #443_automatically_invalidate_connection

    (compare)

  • Aug 04 21:32

    lganzzzo on master

    web::client::HttpRequestExecuto… Merge pull request #456 from oa… (compare)

  • Aug 04 21:32
    lganzzzo closed #456
  • Aug 04 21:19
    lganzzzo opened #456
  • Aug 04 21:18

    lganzzzo on #443_automatically_invalidate_connection

    web::client::HttpRequestExecuto… (compare)

  • Aug 04 18:19

    lganzzzo on #443_automatically_invalidate_connection

    (compare)

  • Aug 04 18:18

    lganzzzo on master

    web::client::HttpRequestExecuto… Merge pull request #455 from oa… (compare)

  • Aug 04 18:18
    lganzzzo closed #455
  • Aug 04 18:02
    lganzzzo opened #455
  • Aug 04 18:01

    lganzzzo on #443_automatically_invalidate_connection

    web::client::HttpRequestExecuto… (compare)

  • Aug 04 12:17
    lganzzzo closed #380
  • Aug 04 12:14
    lganzzzo commented #304
  • Aug 04 11:09
    bamkrs commented #380
  • Aug 04 11:08
    bamkrs commented #380
  • Aug 04 11:02
    bamkrs commented #304
  • Aug 03 22:40
    lganzzzo synchronize #453
  • Aug 03 22:40

    lganzzzo on v1.3.0

    provider::Pool::createShared: A… Merge branch 'v1.3.0' of github… (compare)

  • Aug 03 22:38
    lganzzzo synchronize #453
  • Aug 03 22:38

    lganzzzo on v1.3.0

    Update 1.3.0.md (compare)

junyama
@junyama

Hey @junyama ,
Just pass myClassInstancePoniter as a parameter to constructor of WSListener

It worked! I have just defined a private function instead of using OATTP_COMPONENT for websocket. thank you.

alex-wakizashi
@alex-wakizashi

Hello, @oatpp_io_twitter , thanks for answer - but I don't see any examples how to define more complex DB structure for DTOs with ORM, which contains references to other DTOs, or contain lists, etc.
For example:

class MyDto : public oatpp::DTO {
DTO_INIT(MyDto, DTO)

DTO_FIELD(Int64, id);
DTO_FIELD(List<Int32>, some_nums);
DTO_FIELD(List<Int32>, other_nums);
}
So, what will be DB schema for DTO like this?

Or, for example, references to other objects:

class MyChildDto : public oatpp::DTO {
DTO_INIT(MyChildDto, DTO)

DTO_FIELD(Int64, id);
DTO_FIELD(String, name);
}

class MyParendDto : public oatpp::DTO {
DTO_INIT(MyParentDto, DTO)

DTO_FIELD(Int64, id);
DTO_FIELD(List<MyChildDTO>, childrens);
}

What will be DB schemas for such a structure? Is there specific name convention - how to name fields and related DB tables, so ORM will recognize these?

Zach
@acidtonic
In short how we do it, every DTO has an id field, type string (guid), any related fields are named whatever_field_id on the same dto type string. Then for joining you just set the correct values for the guids on the dto and pass those to the query where conditions
alex-wakizashi
@alex-wakizashi

Hello, Zach,

In short how we do it, every DTO has an id field, type string (guid), any related fields are named whatever_field_id on the same dto type string. Then for joining you just set the correct values for the guids on the dto and pass those to the query where conditions

Ok, got it.

So, to get whole object I need to make few queries:

  1. get row from MyDto DB with given id;
  2. get rows from "some_nums" table with MyDto id,
  3. same for "other_nums" table,
  4. place it to DTO manually,
    correct?

And to implement Lazy Load - define getter... And there is no state control - transient/persistent...

Well, that will work... For simple projects.

But typical "Object Relational Mapping" design template implementation should do it automatically, AFAIK...

Ok. I will try to create few examples - probably, I'm not only person, confused with oat++ ORM :))
It requires database knowledge, which ORM template is designed to hide :)

Zach
@acidtonic

I'm not sure what you mean by "whole object" but normally for our services we have a dto per "class" and we make individual calls to either list or fetch a single object. Then we may grab it's id and use that in another call to get some other class that relates to it.... that call returns a different dto.

We never "combine" them or anything like that. The processing happens as we go. I hope that helps

oat++
@oatpp_io_twitter

Hello @n-sakai0313 ,

Could you please tell me how to use "void Server::run(std::function<bool()> conditional)"? I would like to stop network::Server.
I tried to request to Server via conditional function that I would set false to stop the Server, bud didn't work. Are there any prerequisites? For instance, ServerConnectionProvider must be stopped in advance.

Please checkout this example project with server-stop examples - https://github.com/oatpp/example-server-stop/blob/master/src/App_RunAndStopInFunctions.cpp#L68

Hello @adeolaibigbemi ,

Hi I am trying to get the body parameter sent to my endpoint. How can I do this

Please clarify what exactly you want to do?
You may use curl from the command line to test your endpoints.

Nao SAKAI
@n-sakai0313
@oatpp_io_twitter Thanks a lot, that did it for me!
Chan Mo-Che
@mochechan
Hello. I am attempting to use oatpp to integrate with my code. I studied oatpp documents, and not yet useful tips was found so far. What I want to create is that a restful server can response recognized results for uploading image files. I can upload files via multipart based on oatpp-starter, but I have no idea to modify oatpp-starter to call/use my existing code.
For this question, I was create an issue oatpp/oatpp-starter#15
How can I find documents/hints for the specific question?
oat++
@oatpp_io_twitter

Hello @mochechan ,

I'm not sure If I understand your question correctly.

If you take a look at the example-crud there is a service class - which saves/reads received JSONs to/from DB.

You can modify that service - to process images.

roodani
@roodani

Hello @oatpp_io_twitter

Since there is few differences between the oatpp 1.0 and oatpp 1.2.5 in the src/code layout, for instance in in oatpp.1.0 the Server.hpp is in the oatpp/network/server/Server.hpp and in oatpp.1.2.5 it’s in oatpp/network/Server.hpp.

Therefore, the first idea is to use some conditional directive ex :

#if (OATPP_VERSION < 1.2 )
#include "oatpp/network/server/Server.hpp" 
#else 
#include "oatpp/network/Server.hpp"
#endif

Now this doesn’t work since OATPP_VERSION is defined as a string, won’t be interesting to add :

#define OATPP_VERSION_MAJOR       1
#define OATPP_VERSION_MINOR       2
#define OATPP_VERSION_REVISION 5

this is based on opencv directives definitions

Denis
@elgatito
@oatpp_io_twitter If I use usual sync (not async) endpoints, I have a change to block new requests receiving if I'm waiting for some time to return a response?
I was thinking that receiving of requests is async in oatpp itself, so if I have long running response preparations - I'm not blocking getting other requests, no?
Denis
@elgatito
I have checked that by placing a long sleep. So it is not blocking other requests
Claudio Barca
@clabnet
Hi all, how to converto oatpp:String to wide string (wstring) ?
Why "no suitable user-defined conversion from "const oatpp::String" to "const std::string" " ?
Sorry, I'm burn out.
oat++
@oatpp_io_twitter
Hey @roodani ,
Do you really want to support multiple oatpp versions?
You should know that we are supporting only the latest oatpp version, all old versions are considered deprecated as for origin.
Hey @elgatito ,
Simple API processes each connection in a different thread. Even if one client blocks forever other clients are still getting served.
oat++
@oatpp_io_twitter

Hello @clabnet

Hi all, how to converto oatpp:String to wide string (wstring)

oatpp::String is just a buffer of bytes. You can interpret it as you like.
If you need to convert oatpp::String to wstring - you have to manually perform the conversion accounting for the correct encoding of utf chars with code > 127

Why "no suitable user-defined conversion from "const oatpp::String" to "const std::string" " ?
  oatpp::String s1 = "Hello";
  std::string s2 = s1->std_str();
  const std::string s3 = s1->std_str();
Denis
@elgatito
@oatpp_io_twitter Kind of dummy question. How to globally set Server header? Interceptor?
Denis
@elgatito
@oatpp_io_twitter I'm trying to debug an issue from on of the users. It is running on windows-x86. In the log I log incoming request headers and headers before I return the response from controller:
2021-07-31 09:55:32.593 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Request Header: Method = GET
2021-07-31 09:55:32.594 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Request Header: Accept = */*
2021-07-31 09:55:32.595 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Request Header: Accept-Charset = UTF-8,*;q=0.8
2021-07-31 09:55:32.595 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Request Header: Accept-Encoding = deflate, gzip, br
2021-07-31 09:55:32.596 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Request Header: Host = 127.0.0.1:65225
2021-07-31 09:55:32.597 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Request Header: Range = bytes=1002024533-
2021-07-31 09:55:32.597 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Request Header: User-Agent = Kodi/19.1 (Windows NT 10.0.17763.379; Win64; x64) App_Bitness/64 Version/19.1-(19.1.0)-Git:20210508-85e05228b4
2021-07-31 09:55:32.598 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Response Header: Accept-Ranges = bytes
2021-07-31 09:55:32.599 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Response Header: Connection = keep-alive
2021-07-31 09:55:32.599 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Response Header: Content-Range = bytes 1002024533-9497299626/9497299627
2021-07-31 09:55:32.599 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | FilesController::stream > Response Header: Content-Type = video/x-matroska
2021-07-31 09:55:32.600 T:7836  WARNING <general>: [service.lt2http] [2021-07-31 09:55:32] DEBU | HTTP::Log > [206] GET http://127.0.0.1:65225/torrents/9ee2eda0db939f6b8972cb2d6c94713d7c847e22/files/0/stream/Those.Who.Wish.Me.Dead.2021.D.MVO.BDRip.1080p.seleZen.mkv
Last line is printed by response interceptor, so it looks all good
But on the requestor side it shows strange error:
2021-07-31 09:55:32.600 T:9128    DEBUG <general>: Curl::Debug - TEXT: Received HTTP/0.9 when not allowed
2021-07-31 09:55:32.600 T:9128    DEBUG <general>: Curl::Debug - TEXT: Closing connection 1
2021-07-31 09:55:32.600 T:9128    ERROR <general>: CCurlFile::FillBuffer - Failed: Unsupported protocol(1)
Google says that can happen if curl does not receive Status header. But I see no critical errors, no segfaults, nothing there. Like we returned the response, but requestor side says it is not good
@oatpp_io_twitter Maybe you can have any ideas what to try?
Denis
@elgatito
@oatpp_io_twitter it looks that it was caused by v_buff_size in EmptyBody. ElementumOrg/lt2http@670148a
Users are testing the fix
oat++
@oatpp_io_twitter

Hey @elgatito ,

@oatpp_io_twitter Kind of dummy question. How to globally set Server header? Interceptor?

You may just add the ResponseInterceptor and there you can put Server header

Google says that can happen if curl does not receive Status header. But I see no critical errors, no segfaults, nothing there. Like we returned the response, but requestor side says it is not good

Please use the -v --raw params for curl:

curl "http://..."  -v --raw
oat++
@oatpp_io_twitter
This will print the raw response as-it-is.
Thus we'll be able to see if the response comes back corrupted or if it's invalid
mmjvox
@mmjvox
How to return OutgoingResponse::createShared in ENDPOINT_ASYNC?
I want to download file asynchronously.
Denis
@elgatito

This will print the raw response as-it-is.
Thus we'll be able to see if the response comes back corrupted or if it's invalid

That project is using curl bindings. Probably they treated Transfer-Encoding header in a special way. Users say bug is fixed, so it is fine now.

oat++
@oatpp_io_twitter

Hey @elgatito ,

That project is using curl bindings. Probably they treated Transfer-Encoding header in a special way. Users say bug is fixed, so it is fine now.

Thanks for the info. Please let me know if anything changes.

priyankab453
@priyankab453
ENDPOINT("GET", "/users/{userId}", getUserById,
PATH(Int64, userId))
{
OATPP_LOGD("Test", "userId=%d", userId->getValue());
return createResponse(Status::CODE_200, "OK");
}
getValue() is not working
priyankab453
@priyankab453
can anyone help
oat++
@oatpp_io_twitter
Try *userId instead
What oatpp version are you using ?
priyankab453
@priyankab453
Thanks it worked
1.2.5 version
mmjvox
@mmjvox
I want to download file asynchronously, is there an example?
oat++
@oatpp_io_twitter

Hey @mmjvox ,

If file is small - you can just use the regular buffered response:

  • read file to string
  • return string.

If file is big - use streaming download with StreamingBody

Please let me know if you need more details

Denis
@elgatito
@oatpp_io_twitter How can I get the RemoteAddr for a request?
Benedikt-Alexander Mokroß
@bamkrs
hey @elgatito in your components where you create the ConnectionProvider, you have to set the second parameter of the constructor true ConnectionProvider(const network::Address& address, bool useExtendedConnections = false)
Denis
@elgatito
@bamkrs yes, enabled it. then where it is stored?
Benedikt-Alexander Mokroß
@bamkrs
Ah, yes sorry! Its pretty easy, its stored in the request-object and you can have OATPP give you the request-object in your endpoint:
ENDPOINT("GET", "/", root, 
          REQUEST(std::shared_ptr<IncomingRequest>, request)) 
 {
   auto* context = request->getConnection()->getInputStreamContext();
   for(const auto& pair : context->getProperties().getAll()) {
     OATPP_LOGD("property", "'%s' - '%s'", pair.first.getData(), pair.second.getData());
   }
   return createResponse(Status::CODE_200, "Hello World!!!");
 }
Its stored inside the connections properties, you are looking for the property ExtendedConnection::PROPERTY_PEER_ADDRESS and ExtendedConnection::PROPERTY_PEER_PORT
which translate to the keys peer_address and peer_port
Denis
@elgatito
@bamkrs thanks. this one works:
auto address = request->getConnection()->getInputStreamContext().getProperties().get(oatpp::network::tcp::server::ConnectionProvider::ExtendedConnection::PROPERTY_PEER_ADDRESS);