E503_SERVICE_UNAVAILABLE
} siri_api_header_t;
+typedef enum
+{
+ SIRI_API_FLAG_SERVICE_AUTHENTICATED =1<<0,
+ SIRI_API_FLAG_MESSAGE_COMPLETED =1<<1,
+} siri_api_flags_t;
+
typedef struct siri_api_request_s siri_api_request_t;
typedef int (*on_state_cb_t)(siri_api_request_t * ar, const char * at, size_t n);
siri_api_content_t content_type;
siri_api_req_t request_type;
service_request_t service_type;
- _Bool service_authenticated;
+ siri_api_flags_t flags;
http_parser parser;
uv_write_t req;
};
* Note that debian alpha packages should use versions like this:
* 2.0.34-0alpha0
*/
-#define SIRIDB_VERSION_PRE_RELEASE "-alpha-5"
+#define SIRIDB_VERSION_PRE_RELEASE "-alpha-6"
#ifndef NDEBUG
#define SIRIDB_VERSION_BUILD_RELEASE "+debug"
ar->len = 0;
ar->size = 0;
ar->on_state = NULL;
- ar->service_authenticated = 0;
+ ar->flags = 0;
ar->request_type = SIRI_API_RT_NONE;
ar->content_type = SIRI_API_CT_TEXT;
}
goto done;
}
- api__reset(ar);
+ if (ar->flags & SIRI_API_FLAG_MESSAGE_COMPLETED)
+ api__reset(ar);
buf->base[HTTP_MAX_HEADER_SIZE-1] = '\0';
{
if (ar->request_type == SIRI_APT_RT_SERVICE)
{
- ar->service_authenticated = siri_service_account_check_basic(
- &siri, at, n);
+ if (siri_service_account_check_basic(&siri, at, n))
+ ar->flags |= SIRI_API_FLAG_SERVICE_AUTHENTICATED;
return 0;
}
siridb_user_t * user;
break;
}
- if (!ar->service_authenticated)
+ if (~ar->flags & SIRI_API_FLAG_SERVICE_AUTHENTICATED)
return api__plain_response(ar, E401_UNAUTHORIZED);
switch (ar->content_type)
{
siri_api_request_t * ar = parser->data;
+ ar->flags |= SIRI_API_FLAG_MESSAGE_COMPLETED;
+
switch(ar->request_type)
{
case SIRI_API_RT_NONE: