forked from lda/telodendria
Clean up a few bugs in HttpClient and Uri
This commit is contained in:
parent
3e42da279c
commit
7e144ae488
4 changed files with 17 additions and 6 deletions
1
TODO.txt
1
TODO.txt
|
@ -18,6 +18,7 @@ Milestone: v0.3.0
|
|||
[~] HTTP Client API
|
||||
[ ] Document HttpParseHeaders()
|
||||
[ ] HttpClient man page
|
||||
[ ] Uia man page
|
||||
[ ] Test on other platforms
|
||||
[ ] Option to pretty-print Json
|
||||
|
||||
|
|
|
@ -75,8 +75,6 @@ HttpRequest(HttpRequestMethod method, int flags, unsigned short port, char *host
|
|||
sprintf(serv, "%hu", port);
|
||||
}
|
||||
|
||||
printf("serv = %s\n", serv);
|
||||
|
||||
/* TODO: Not supported yet */
|
||||
if (flags & HTTP_TLS)
|
||||
{
|
||||
|
@ -157,6 +155,18 @@ HttpRequestHeader(HttpClientContext * context, char *key, char *val)
|
|||
fprintf(context->stream, "%s: %s\r\n", key, val);
|
||||
}
|
||||
|
||||
void
|
||||
HttpRequestSendHeaders(HttpClientContext * context)
|
||||
{
|
||||
if (!context)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(context->stream, "\r\n");
|
||||
fflush(context->stream);
|
||||
}
|
||||
|
||||
HttpStatus
|
||||
HttpRequestSend(HttpClientContext * context)
|
||||
{
|
||||
|
@ -172,9 +182,6 @@ HttpRequestSend(HttpClientContext * context)
|
|||
return 0;
|
||||
}
|
||||
|
||||
fprintf(context->stream, "\r\n");
|
||||
fflush(context->stream);
|
||||
|
||||
lineLen = UtilGetLine(&line, &lineSize, context->stream);
|
||||
|
||||
/* Line must contain at least "HTTP/x.x xxx" */
|
||||
|
|
|
@ -49,7 +49,7 @@ UriParse(const char *str)
|
|||
|
||||
res = sscanf(str, "%7[^:]://%127[^:]:%hu%255[^\n]", uri->proto, uri->host, &uri->port, uri->path) == 4
|
||||
|| sscanf(str, "%7[^:]://%127[^/]%255[^\n]", uri->proto, uri->host, uri->path) == 3
|
||||
|| sscanf(str, "%7[^:]://%127[^:]%hu[^\n]", uri->proto, uri->host, &uri->port) == 3
|
||||
|| sscanf(str, "%7[^:]://%127[^:]:%hu[^\n]", uri->proto, uri->host, &uri->port) == 3
|
||||
|| sscanf(str, "%7[^:]://%127[^\n]", uri->proto, uri->host) == 2;
|
||||
|
||||
if (!res)
|
||||
|
|
|
@ -40,6 +40,9 @@ extern HttpClientContext *
|
|||
extern void
|
||||
HttpRequestHeader(HttpClientContext *, char *, char *);
|
||||
|
||||
extern void
|
||||
HttpRequestSendHeaders(HttpClientContext *);
|
||||
|
||||
extern HttpStatus
|
||||
HttpRequestSend(HttpClientContext *);
|
||||
|
||||
|
|
Loading…
Reference in a new issue