Skip to content

Commit

Permalink
Add HTTP request parsing.
Browse files Browse the repository at this point in the history
This extends the existing http parser to support requests as well as responses.

httpcli continues to exist and work as it has previously, though in the new
directory src/core/http (to reflect the fact the directory now contains code
relevant to parsing requests, which httpcli would not generally involve itself
in).
  • Loading branch information
miselin committed Mar 23, 2016
1 parent 39fd221 commit 1824f05
Show file tree
Hide file tree
Showing 45 changed files with 884 additions and 649 deletions.
40 changes: 20 additions & 20 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ cc_library(
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/http/format_request.h",
"src/core/http/httpcli.h",
"src/core/http/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
Expand Down Expand Up @@ -331,9 +331,9 @@ cc_library(
"src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/http/format_request.c",
"src/core/http/httpcli.c",
"src/core/http/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
Expand Down Expand Up @@ -429,7 +429,7 @@ cc_library(
"src/core/transport/static_metadata.c",
"src/core/transport/transport.c",
"src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c",
"src/core/security/client_auth_filter.c",
"src/core/security/credentials.c",
Expand Down Expand Up @@ -562,9 +562,9 @@ cc_library(
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/http/format_request.h",
"src/core/http/httpcli.h",
"src/core/http/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
Expand Down Expand Up @@ -690,9 +690,9 @@ cc_library(
"src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/http/format_request.c",
"src/core/http/httpcli.c",
"src/core/http/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
Expand Down Expand Up @@ -1390,9 +1390,9 @@ objc_library(
"src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/http/format_request.c",
"src/core/http/httpcli.c",
"src/core/http/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
Expand Down Expand Up @@ -1488,7 +1488,7 @@ objc_library(
"src/core/transport/static_metadata.c",
"src/core/transport/transport.c",
"src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c",
"src/core/security/client_auth_filter.c",
"src/core/security/credentials.c",
Expand Down Expand Up @@ -1566,9 +1566,9 @@ objc_library(
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/http/format_request.h",
"src/core/http/httpcli.h",
"src/core/http/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
Expand Down
68 changes: 34 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,8 @@ grpc_security_connector_test: $(BINDIR)/$(CONFIG)/grpc_security_connector_test
grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt
hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test
hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test
http_parser_test: $(BINDIR)/$(CONFIG)/http_parser_test
httpcli_format_request_test: $(BINDIR)/$(CONFIG)/httpcli_format_request_test
httpcli_parser_test: $(BINDIR)/$(CONFIG)/httpcli_parser_test
httpcli_test: $(BINDIR)/$(CONFIG)/httpcli_test
httpscli_test: $(BINDIR)/$(CONFIG)/httpscli_test
init_test: $(BINDIR)/$(CONFIG)/init_test
Expand Down Expand Up @@ -1236,8 +1236,8 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/grpc_security_connector_test \
$(BINDIR)/$(CONFIG)/hpack_parser_test \
$(BINDIR)/$(CONFIG)/hpack_table_test \
$(BINDIR)/$(CONFIG)/http_parser_test \
$(BINDIR)/$(CONFIG)/httpcli_format_request_test \
$(BINDIR)/$(CONFIG)/httpcli_parser_test \
$(BINDIR)/$(CONFIG)/httpcli_test \
$(BINDIR)/$(CONFIG)/httpscli_test \
$(BINDIR)/$(CONFIG)/init_test \
Expand Down Expand Up @@ -1522,10 +1522,10 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/hpack_parser_test || ( echo test hpack_parser_test failed ; exit 1 )
$(E) "[RUN] Testing hpack_table_test"
$(Q) $(BINDIR)/$(CONFIG)/hpack_table_test || ( echo test hpack_table_test failed ; exit 1 )
$(E) "[RUN] Testing http_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/http_parser_test || ( echo test http_parser_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_format_request_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_format_request_test || ( echo test httpcli_format_request_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_parser_test || ( echo test httpcli_parser_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_test || ( echo test httpcli_test failed ; exit 1 )
$(E) "[RUN] Testing httpscli_test"
Expand Down Expand Up @@ -2437,9 +2437,9 @@ LIBGRPC_SRC = \
src/core/compression/compression_algorithm.c \
src/core/compression/message_compress.c \
src/core/debug/trace.c \
src/core/httpcli/format_request.c \
src/core/httpcli/httpcli.c \
src/core/httpcli/parser.c \
src/core/http/format_request.c \
src/core/http/httpcli.c \
src/core/http/parser.c \
src/core/iomgr/closure.c \
src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \
Expand Down Expand Up @@ -2535,7 +2535,7 @@ LIBGRPC_SRC = \
src/core/transport/static_metadata.c \
src/core/transport/transport.c \
src/core/transport/transport_op_string.c \
src/core/httpcli/httpcli_security_connector.c \
src/core/http/httpcli_security_connector.c \
src/core/security/b64.c \
src/core/security/client_auth_filter.c \
src/core/security/credentials.c \
Expand Down Expand Up @@ -2797,9 +2797,9 @@ LIBGRPC_UNSECURE_SRC = \
src/core/compression/compression_algorithm.c \
src/core/compression/message_compress.c \
src/core/debug/trace.c \
src/core/httpcli/format_request.c \
src/core/httpcli/httpcli.c \
src/core/httpcli/parser.c \
src/core/http/format_request.c \
src/core/http/httpcli.c \
src/core/http/parser.c \
src/core/iomgr/closure.c \
src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \
Expand Down Expand Up @@ -7757,72 +7757,72 @@ endif
endif


HTTPCLI_FORMAT_REQUEST_TEST_SRC = \
test/core/httpcli/format_request_test.c \
HTTP_PARSER_TEST_SRC = \
test/core/http/parser_test.c \

HTTPCLI_FORMAT_REQUEST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FORMAT_REQUEST_TEST_SRC))))
HTTP_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_PARSER_TEST_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/httpcli_format_request_test: openssl_dep_error
$(BINDIR)/$(CONFIG)/http_parser_test: openssl_dep_error

else



$(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/http_parser_test: $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test
$(Q) $(LD) $(LDFLAGS) $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_parser_test

endif

$(OBJDIR)/$(CONFIG)/test/core/httpcli/format_request_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
deps_http_parser_test: $(HTTP_PARSER_TEST_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
-include $(HTTP_PARSER_TEST_OBJS:.o=.dep)
endif
endif


HTTPCLI_PARSER_TEST_SRC = \
test/core/httpcli/parser_test.c \
HTTPCLI_FORMAT_REQUEST_TEST_SRC = \
test/core/http/format_request_test.c \

HTTPCLI_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_PARSER_TEST_SRC))))
HTTPCLI_FORMAT_REQUEST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FORMAT_REQUEST_TEST_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/httpcli_parser_test: openssl_dep_error
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: openssl_dep_error

else



$(BINDIR)/$(CONFIG)/httpcli_parser_test: $(HTTPCLI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_parser_test
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test

endif

$(OBJDIR)/$(CONFIG)/test/core/httpcli/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/format_request_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_httpcli_parser_test: $(HTTPCLI_PARSER_TEST_OBJS:.o=.dep)
deps_httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTPCLI_PARSER_TEST_OBJS:.o=.dep)
-include $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
endif
endif


HTTPCLI_TEST_SRC = \
test/core/httpcli/httpcli_test.c \
test/core/http/httpcli_test.c \

HTTPCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true)
Expand All @@ -7842,7 +7842,7 @@ $(BINDIR)/$(CONFIG)/httpcli_test: $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgr

endif

$(OBJDIR)/$(CONFIG)/test/core/httpcli/httpcli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/httpcli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_httpcli_test: $(HTTPCLI_TEST_OBJS:.o=.dep)

Expand All @@ -7854,7 +7854,7 @@ endif


HTTPSCLI_TEST_SRC = \
test/core/httpcli/httpscli_test.c \
test/core/http/httpscli_test.c \

HTTPSCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPSCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true)
Expand All @@ -7874,7 +7874,7 @@ $(BINDIR)/$(CONFIG)/httpscli_test: $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/lib

endif

$(OBJDIR)/$(CONFIG)/test/core/httpcli/httpscli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/httpscli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_httpscli_test: $(HTTPSCLI_TEST_OBJS:.o=.dep)

Expand Down Expand Up @@ -13378,7 +13378,7 @@ ifneq ($(OPENSSL_DEP),)
# This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first.
src/core/httpcli/httpcli_security_connector.c: $(OPENSSL_DEP)
src/core/http/httpcli_security_connector.c: $(OPENSSL_DEP)
src/core/security/b64.c: $(OPENSSL_DEP)
src/core/security/client_auth_filter.c: $(OPENSSL_DEP)
src/core/security/credentials.c: $(OPENSSL_DEP)
Expand Down
8 changes: 4 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@
'src/core/compression/compression_algorithm.c',
'src/core/compression/message_compress.c',
'src/core/debug/trace.c',
'src/core/httpcli/format_request.c',
'src/core/httpcli/httpcli.c',
'src/core/httpcli/parser.c',
'src/core/http/format_request.c',
'src/core/http/httpcli.c',
'src/core/http/parser.c',
'src/core/iomgr/closure.c',
'src/core/iomgr/endpoint.c',
'src/core/iomgr/endpoint_pair_posix.c',
Expand Down Expand Up @@ -690,7 +690,7 @@
'src/core/transport/static_metadata.c',
'src/core/transport/transport.c',
'src/core/transport/transport_op_string.c',
'src/core/httpcli/httpcli_security_connector.c',
'src/core/http/httpcli_security_connector.c',
'src/core/security/b64.c',
'src/core/security/client_auth_filter.c',
'src/core/security/credentials.c',
Expand Down
26 changes: 13 additions & 13 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ filegroups:
- src/core/compression/algorithm_metadata.h
- src/core/compression/message_compress.h
- src/core/debug/trace.h
- src/core/httpcli/format_request.h
- src/core/httpcli/httpcli.h
- src/core/httpcli/parser.h
- src/core/http/format_request.h
- src/core/http/httpcli.h
- src/core/http/parser.h
- src/core/iomgr/closure.h
- src/core/iomgr/endpoint.h
- src/core/iomgr/endpoint_pair.h
Expand Down Expand Up @@ -401,9 +401,9 @@ filegroups:
- src/core/compression/compression_algorithm.c
- src/core/compression/message_compress.c
- src/core/debug/trace.c
- src/core/httpcli/format_request.c
- src/core/httpcli/httpcli.c
- src/core/httpcli/parser.c
- src/core/http/format_request.c
- src/core/http/httpcli.c
- src/core/http/parser.c
- src/core/iomgr/closure.c
- src/core/iomgr/endpoint.c
- src/core/iomgr/endpoint_pair_posix.c
Expand Down Expand Up @@ -524,7 +524,7 @@ filegroups:
- src/core/tsi/transport_security.h
- src/core/tsi/transport_security_interface.h
src:
- src/core/httpcli/httpcli_security_connector.c
- src/core/http/httpcli_security_connector.c
- src/core/security/b64.c
- src/core/security/client_auth_filter.c
- src/core/security/credentials.c
Expand Down Expand Up @@ -1560,21 +1560,21 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: httpcli_format_request_test
- name: http_parser_test
build: test
language: c
src:
- test/core/httpcli/format_request_test.c
- test/core/http/parser_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: httpcli_parser_test
- name: httpcli_format_request_test
build: test
language: c
src:
- test/core/httpcli/parser_test.c
- test/core/http/format_request_test.c
deps:
- grpc_test_util
- grpc
Expand All @@ -1585,7 +1585,7 @@ targets:
build: test
language: c
src:
- test/core/httpcli/httpcli_test.c
- test/core/http/httpcli_test.c
deps:
- grpc_test_util
- grpc
Expand All @@ -1600,7 +1600,7 @@ targets:
build: test
language: c
src:
- test/core/httpcli/httpscli_test.c
- test/core/http/httpscli_test.c
deps:
- grpc_test_util
- grpc
Expand Down
Loading

0 comments on commit 1824f05

Please sign in to comment.