-
Notifications
You must be signed in to change notification settings - Fork 208
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
add http server test #134
Open
helight
wants to merge
2
commits into
envoyproxy:main
Choose a base branch
from
helight:add_test_config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add http server test #134
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
admin: | ||
access_log_path: /dev/null | ||
address: | ||
socket_address: | ||
address: 127.0.0.1 | ||
port_value: 0 | ||
static_resources: | ||
clusters: | ||
name: cluster_0 | ||
connect_timeout: 0.25s | ||
load_assignment: | ||
cluster_name: cluster_0 | ||
endpoints: | ||
- lb_endpoints: | ||
- endpoint: | ||
address: | ||
socket_address: | ||
address: 127.0.0.1 | ||
port_value: 8081 | ||
listeners: | ||
- name: listener_0 | ||
address: | ||
socket_address: | ||
address: 127.0.0.1 | ||
port_value: 8080 | ||
filter_chains: | ||
- filters: | ||
- name: envoy.http_connection_manager | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager | ||
stat_prefix: ingress_http | ||
codec_type: auto | ||
route_config: | ||
name: local_route | ||
virtual_hosts: | ||
- name: local_service | ||
domains: | ||
- "*" | ||
routes: | ||
- match: | ||
prefix: "/" | ||
route: | ||
cluster: cluster_0 | ||
http_filters: | ||
- name: sample # before envoy.router because order matters! | ||
typed_config: | ||
"@type": type.googleapis.com/sample.Decoder | ||
key: vIa | ||
val: sample-filter | ||
- name: envoy.router | ||
typed_config: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/python3 | ||
from http.server import BaseHTTPRequestHandler,HTTPServer | ||
|
||
HTTP_PORT = 8081 | ||
|
||
# This class will handles any incoming request | ||
class doHandler(BaseHTTPRequestHandler): | ||
|
||
# Handler for the GET requests | ||
def do_GET(self): | ||
self.send_response(200) | ||
self.send_header('Content-type','text/html') | ||
self.end_headers() | ||
print(self.headers) | ||
# Send the message | ||
self.wfile.write(b"Hello World !\r\n") | ||
self.wfile.write(self.headers.as_bytes()) | ||
return | ||
|
||
try: | ||
# Create a http server and define the handler to manage the request | ||
server = HTTPServer(('', HTTP_PORT), doHandler) | ||
print('Started httpserver on port ' , HTTP_PORT) | ||
|
||
# Wait forever for incoming http requests | ||
server.serve_forever() | ||
|
||
except KeyboardInterrupt: | ||
print('^C received, shutting down the web server') | ||
server.socket.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
python3 ./http-filter-example/httpserver.py& | ||
./bazel-bin/envoy --config-path ./http-filter-example/config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash -e | ||
|
||
export NAME=http-filter-example | ||
|
||
_curl () { | ||
local arg curl_command | ||
curl_command=(curl -s) | ||
if [[ ! "$*" =~ "-X" ]]; then | ||
curl_command+=(-X GET) | ||
fi | ||
for arg in "${@}"; do | ||
curl_command+=("$arg") | ||
done | ||
"${curl_command[@]}" || { | ||
echo "ERROR: curl (${curl_command[*]})" >&2 | ||
return 1 | ||
} | ||
} | ||
|
||
responds_with () { | ||
local expected | ||
expected="$1" | ||
shift | ||
_curl "${@}" | grep "$expected" || { | ||
echo "ERROR: curl expected (${*}): $expected" >&2 | ||
return 1 | ||
} | ||
} | ||
|
||
responds_with \ | ||
"via: sample-filter" \ | ||
"http://localhost:8080" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: keep this lowercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for testing this function
http_filter.cc