Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose evhttp_get_request to user #1471

Open
MBeanwenshengming opened this issue Jun 6, 2023 · 11 comments
Open

expose evhttp_get_request to user #1471

MBeanwenshengming opened this issue Jun 6, 2023 · 11 comments
Labels
subsystem:http HTTP Related issue
Milestone

Comments

@MBeanwenshengming
Copy link
Contributor

can you expose evhttp_get_request to user?

i have a listen thread and some work threads, work threads(IO thread) use evhttp_new create http server

my listen thread send socket to work threads by load, work thread use evhttp_get_request create http service(i modify it local)

i mainly use libevent for websocket.

thank you!!

@mllw
Copy link

mllw commented Jul 3, 2023

I have the same needs

@azat
Copy link
Member

azat commented Jul 9, 2023

@MBeanwenshengming I'm not sure that it worth to export this internal function, so is there any reason for not using multiple http servers per-thread with SO_REUSEPORT?

@azat azat added the subsystem:http HTTP Related issue label Jul 9, 2023
@mllw
Copy link

mllw commented Jul 10, 2023

Before using the http protocol, I need to detect the other network protocols.

@azat
Copy link
Member

azat commented Jul 10, 2023

@widgetii what do you think about exporting this function?

@MBeanwenshengming
Copy link
Contributor Author

MBeanwenshengming commented Jul 10, 2023

@azat My needs are essentially the same with mllw, export evhttp_get_request to user, It can make the user more flexible. thanks!
our server use libevent for tcp too.

@widgetii
Copy link
Member

@widgetii what do you think about exporting this function?

I have no objections personally if it helps to our library users

@azat
Copy link
Member

azat commented Jul 10, 2023

Ok, let's do this. And since we have a real users, @MBeanwenshengming or @mllw can you submit a pull request that will export it and also add some unit test with some real example into test/regress_http.c?

@mllw
Copy link

mllw commented Jul 11, 2023

I added a one by one function based on 4d85d28 and patched it, now it works fine, you can simply add this patch to vcpkg to use it。

in vcpkg ports/libevent/portfile.cmake
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO libevent/libevent
REF 4d85d28
SHA512 d03daf8e2277e8b9d67e0028d05566c8972a706e53dcb6593f8f92942ff9ce814970418a10d4c37e68228ec153f8fbc7d764a7ff92e2872277a92039380cbbe9
PATCHES
fix-uwp.patch
fix-file_path.patch
fix-LibeventConfig_cmake_in_path.patch
fix-usage.patch
http_add_get.patch
)

http_add_get.patch

@mllw
Copy link

mllw commented Jul 11, 2023

I think expose evhttp_get_request_bufferevent is better than evhttp_get_request

@MBeanwenshengming
Copy link
Contributor Author

i just add a export function to http.h

EVENT2_EXPORT_SYMBOL
void evhttp_get_request_app(struct evhttp http, evutil_socket_t fd,
struct sockaddr
sockaddr, ev_socklen_t sockaddrlen, struct bufferevent *bev);

add the following code to http.c

void evhttp_get_request_app(struct evhttp* http, evutil_socket_t fd,
struct sockaddr* sockaddr, ev_socklen_t sockaddrlen,
struct bufferevent* bev)
{
evhttp_get_request(http, fd, sockaddr, sockaddrlen, bev);
}

I'm not very familiar with libevent

but the code can work

i just want to call evhttp_get_request

@azat
Copy link
Member

azat commented Jul 11, 2023

We heed to have unit test as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subsystem:http HTTP Related issue
Development

No branches or pull requests

4 participants