chromium/third_party/grpc/src/src/core/lib/http/parser.h

//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//

#ifndef GRPC_SRC_CORE_LIB_HTTP_PARSER_H
#define GRPC_SRC_CORE_LIB_HTTP_PARSER_H

#include <grpc/support/port_platform.h>

#include <stddef.h>
#include <stdint.h>

#include <grpc/slice.h>

#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/error.h"

// Maximum length of a header string of the form 'Key: Value\r\n'
#define GRPC_HTTP_PARSER_MAX_HEADER_LENGTH

// A single header to be passed in a request
grpc_http_header;

grpc_http_parser_state;

grpc_http_parser_chunked_state;

grpc_http_version;

grpc_http_type;

// A request
grpc_http_request;

// A response
grpc_http_response;

struct grpc_http_parser {};
void grpc_http_parser_init(grpc_http_parser* parser, grpc_http_type type,
                           void* request_or_response);
void grpc_http_parser_destroy(grpc_http_parser* parser);

// Sets \a start_of_body to the offset in \a slice of the start of the body.
grpc_error_handle grpc_http_parser_parse(grpc_http_parser* parser,
                                         const grpc_slice& slice,
                                         size_t* start_of_body);
grpc_error_handle grpc_http_parser_eof(grpc_http_parser* parser);

void grpc_http_request_destroy(grpc_http_request* request);
void grpc_http_response_destroy(grpc_http_response* response);

extern grpc_core::TraceFlag grpc_http1_trace;

#endif  // GRPC_SRC_CORE_LIB_HTTP_PARSER_H