Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
49f02d36
Commit
49f02d36
authored
8 years ago
by
Mark D. Roth
Browse files
Options
Downloads
Patches
Plain Diff
Add support for sending custom headers in HTTP CONNECT request.
parent
6cf58c81
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/ext/client_channel/http_connect_handshaker.c
+22
-2
22 additions, 2 deletions
src/core/ext/client_channel/http_connect_handshaker.c
src/core/ext/client_channel/http_connect_handshaker.h
+4
-1
4 additions, 1 deletion
src/core/ext/client_channel/http_connect_handshaker.h
with
26 additions
and
3 deletions
src/core/ext/client_channel/http_connect_handshaker.c
+
22
−
2
View file @
49f02d36
...
...
@@ -55,6 +55,8 @@ typedef struct http_connect_handshaker {
grpc_handshaker
base
;
char
*
proxy_server
;
grpc_http_header
*
headers
;
size_t
num_headers
;
gpr_refcount
refcount
;
gpr_mu
mu
;
...
...
@@ -90,6 +92,11 @@ static void http_connect_handshaker_unref(grpc_exec_ctx* exec_ctx,
gpr_free
(
handshaker
->
read_buffer_to_destroy
);
}
gpr_free
(
handshaker
->
proxy_server
);
for
(
size_t
i
=
0
;
i
<
handshaker
->
num_headers
;
++
i
)
{
gpr_free
(
handshaker
->
headers
[
i
].
key
);
gpr_free
(
handshaker
->
headers
[
i
].
value
);
}
gpr_free
(
handshaker
->
headers
);
grpc_slice_buffer_destroy_internal
(
exec_ctx
,
&
handshaker
->
write_buffer
);
grpc_http_parser_destroy
(
&
handshaker
->
http_parser
);
grpc_http_response_destroy
(
&
handshaker
->
http_response
);
...
...
@@ -290,6 +297,8 @@ static void http_connect_handshaker_do_handshake(
request
.
host
=
server_name
;
request
.
http
.
method
=
"CONNECT"
;
request
.
http
.
path
=
server_name
;
request
.
http
.
hdrs
=
handshaker
->
headers
;
request
.
http
.
hdr_count
=
handshaker
->
num_headers
;
request
.
handshaker
=
&
grpc_httpcli_plaintext
;
grpc_slice
request_slice
=
grpc_httpcli_format_connect_request
(
&
request
);
grpc_slice_buffer_add
(
&
handshaker
->
write_buffer
,
request_slice
);
...
...
@@ -307,7 +316,9 @@ static const grpc_handshaker_vtable http_connect_handshaker_vtable = {
http_connect_handshaker_destroy
,
http_connect_handshaker_shutdown
,
http_connect_handshaker_do_handshake
};
grpc_handshaker
*
grpc_http_connect_handshaker_create
(
const
char
*
proxy_server
)
{
grpc_handshaker
*
grpc_http_connect_handshaker_create
(
const
char
*
proxy_server
,
grpc_http_header
*
headers
,
size_t
num_headers
)
{
GPR_ASSERT
(
proxy_server
!=
NULL
);
http_connect_handshaker
*
handshaker
=
gpr_malloc
(
sizeof
(
*
handshaker
));
memset
(
handshaker
,
0
,
sizeof
(
*
handshaker
));
...
...
@@ -315,6 +326,14 @@ grpc_handshaker* grpc_http_connect_handshaker_create(const char* proxy_server) {
gpr_mu_init
(
&
handshaker
->
mu
);
gpr_ref_init
(
&
handshaker
->
refcount
,
1
);
handshaker
->
proxy_server
=
gpr_strdup
(
proxy_server
);
if
(
num_headers
>
0
)
{
handshaker
->
headers
=
gpr_malloc
(
sizeof
(
grpc_http_header
)
*
num_headers
);
for
(
size_t
i
=
0
;
i
<
num_headers
;
++
i
)
{
handshaker
->
headers
[
i
].
key
=
gpr_strdup
(
headers
[
i
].
key
);
handshaker
->
headers
[
i
].
value
=
gpr_strdup
(
headers
[
i
].
value
);
}
handshaker
->
num_headers
=
num_headers
;
}
grpc_slice_buffer_init
(
&
handshaker
->
write_buffer
);
grpc_closure_init
(
&
handshaker
->
request_done_closure
,
on_write_done
,
handshaker
,
grpc_schedule_on_exec_ctx
);
...
...
@@ -359,7 +378,8 @@ static void handshaker_factory_add_handshakers(
char
*
proxy_name
=
grpc_get_http_proxy_server
();
if
(
proxy_name
!=
NULL
)
{
grpc_handshake_manager_add
(
handshake_mgr
,
grpc_http_connect_handshaker_create
(
proxy_name
));
grpc_http_connect_handshaker_create
(
proxy_name
,
NULL
,
0
));
gpr_free
(
proxy_name
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/core/ext/client_channel/http_connect_handshaker.h
+
4
−
1
View file @
49f02d36
...
...
@@ -35,9 +35,12 @@
#define GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H
#include
"src/core/lib/channel/handshaker.h"
#include
"src/core/lib/http/parser.h"
/// Creates a new HTTP CONNECT handshaker.
grpc_handshaker
*
grpc_http_connect_handshaker_create
(
const
char
*
proxy_server
);
grpc_handshaker
*
grpc_http_connect_handshaker_create
(
const
char
*
proxy_server
,
grpc_http_header
*
headers
,
size_t
num_headers
);
/// Returns the name of the proxy to use, or NULL if no proxy is configured.
/// Caller takes ownership of result.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment