about summary refs log tree commit diff stats
path: root/source/http.h
blob: 9597a1df0af98856ab647c209c0ec7d8327ce129 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (C) 2008 Tantric
 * Copyright (C) 2012 Pedro Aguiar
 * Copyright (C) 2017 hatkirby
 *
 * Originally part of the WiiTweet project, which was distributed under the
 * GPL.
 */
#ifndef HTTP_H_A46C206E
#define HTTP_H_A46C206E

#include "cJSON.h"
#include <wolfssl/options.h>
#include <wolfssl/ssl.h>

typedef enum {
	HTTPR_OK,
	HTTPR_ERR_CONNECT,
	HTTPR_ERR_TIMEOUT,
  HTTPR_ERR_WRITE,
  HTTPR_ERR_RECEIVE,
  HTTPR_ERR_SSL,
  HTTPR_ERR_STATUS
} http_res;

/**
 * Submits a JSON request to a web service. Takes ownership of the cJSON object,
 * because it needs to embed authentication data in it.
 */
int submitToApi(
  const char* endpoint,
  WOLFSSL_CTX* sslContext,
  cJSON* data,
  const char* username,
  const char* password);

#endif /* end of include guard: HTTP_H_A46C206E */