#ifndef INCLUDE_transports_httpclient_h__
#define INCLUDE_transports_httpclient_h__
#include "common.h"
#include "net.h"
#define GIT_HTTP_STATUS_CONTINUE 100
#define GIT_HTTP_STATUS_OK 200
#define GIT_HTTP_MOVED_PERMANENTLY 301
#define GIT_HTTP_FOUND 302
#define GIT_HTTP_SEE_OTHER 303
#define GIT_HTTP_TEMPORARY_REDIRECT 307
#define GIT_HTTP_PERMANENT_REDIRECT 308
#define GIT_HTTP_STATUS_UNAUTHORIZED 401
#define GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED 407
typedef struct git_http_client git_http_client;
typedef enum {
GIT_HTTP_METHOD_GET,
GIT_HTTP_METHOD_POST,
GIT_HTTP_METHOD_CONNECT
} git_http_method;
typedef struct {
git_http_method method;
git_net_url *url;
git_net_url *proxy;
const char *accept;
const char *content_type;
git_credential *credentials;
git_credential *proxy_credentials;
git_strarray *custom_headers;
size_t content_length;
unsigned chunked : 1,
expect_continue : 1;
} git_http_request;
typedef struct {
int status;
char *content_type;
size_t content_length;
char *location;
unsigned server_auth_schemetypes;
unsigned server_auth_credtypes;
unsigned proxy_auth_schemetypes;
unsigned proxy_auth_credtypes;
unsigned chunked : 1,
resend_credentials : 1;
} git_http_response;
typedef struct {
git_transport_certificate_check_cb server_certificate_check_cb;
void *server_certificate_check_payload;
git_transport_certificate_check_cb proxy_certificate_check_cb;
void *proxy_certificate_check_payload;
} git_http_client_options;
extern int git_http_client_new(
git_http_client **out,
git_http_client_options *opts);
extern int git_http_client_send_request(
git_http_client *client,
git_http_request *request);
extern bool git_http_client_has_response(git_http_client *client);
extern int git_http_client_send_body(
git_http_client *client,
const char *buffer,
size_t buffer_len);
extern int git_http_client_read_response(
git_http_response *response,
git_http_client *client);
extern int git_http_client_read_body(
git_http_client *client,
char *buffer,
size_t buffer_size);
extern int git_http_client_skip_body(git_http_client *client);
extern bool git_http_response_is_redirect(git_http_response *response);
extern void git_http_response_dispose(git_http_response *response);
extern void git_http_client_free(git_http_client *client);
#endif