mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-09 03:22:45 +03:00
Function checked and renamed to httplib_
This commit is contained in:
@@ -32,7 +32,7 @@ the API can be found in [Embedding.md](Embedding.md).
|
|||||||
* [`mg_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user_data);`](api/mg_connect_websocket_client.md)
|
* [`mg_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user_data);`](api/mg_connect_websocket_client.md)
|
||||||
* [`mg_cry( conn, fmt, ... );`](api/mg_cry.md)
|
* [`mg_cry( conn, fmt, ... );`](api/mg_cry.md)
|
||||||
* [`mg_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );`](api/mg_download.md)
|
* [`mg_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );`](api/mg_download.md)
|
||||||
* [`mg_get_builtin_mime_type( file_name );`](api/mg_get_builtin_mime_type.md)
|
* [`httplib_get_builtin_mime_type( file_name );`](api/httplib_get_builtin_mime_type.md)
|
||||||
* [`mg_get_context( conn );`](api/mg_get_context.md)
|
* [`mg_get_context( conn );`](api/mg_get_context.md)
|
||||||
* [`mg_get_cookie( cookie, var_name, buf, buf_len );`](api/mg_get_cookie.md)
|
* [`mg_get_cookie( cookie, var_name, buf, buf_len );`](api/mg_get_cookie.md)
|
||||||
* [`mg_get_header( conn, name );`](api/mg_get_header.md)
|
* [`mg_get_header( conn, name );`](api/mg_get_header.md)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# LibHTTP API Reference
|
# LibHTTP API Reference
|
||||||
|
|
||||||
### `mg_get_builtin_mime_type( file_name );`
|
### `httplib_get_builtin_mime_type( file_name );`
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
### Description
|
### Description
|
||||||
|
|
||||||
The function `mg_get_builtin_mime_type()` tries to determine the MIME type of a given file. If the MIME type cannot be determined, the value `text/plain` is returned. Please note that this function does not an intelligent check of the file contents. The MIME type is solely determined based on the file name extension.
|
The function `httplib_get_builtin_mime_type()` tries to determine the MIME type of a given file. If the MIME type cannot be determined, the value `text/plain` is returned. Please note that this function does not an intelligent check of the file contents. The MIME type is solely determined based on the file name extension.
|
||||||
|
|
||||||
### See Also
|
### See Also
|
||||||
|
|
||||||
|
@@ -21,5 +21,5 @@ The function `mg_get_response_code_text()` returns a pointer to a human readable
|
|||||||
|
|
||||||
### See Also
|
### See Also
|
||||||
|
|
||||||
* [`mg_get_builtin_mime_type();`](mg_get_builtin_mime_type.md)
|
* [`httplib_get_builtin_mime_type();`](httplib_get_builtin_mime_type.md)
|
||||||
* [`mg_version();`](mg_version.md)
|
* [`mg_version();`](mg_version.md)
|
||||||
|
@@ -20,7 +20,7 @@ The function `mg_send_mime_file()` sends a file over a connection including the
|
|||||||
|
|
||||||
### See Also
|
### See Also
|
||||||
|
|
||||||
* [`mg_get_builtin_mime_type();`](mg_get_builtin_mime_type.md)
|
* [`httplib_get_builtin_mime_type();`](httplib_get_builtin_mime_type.md)
|
||||||
* [`mg_printf();`](mg_printf.md)
|
* [`mg_printf();`](mg_printf.md)
|
||||||
* [`mg_send_file();`](mg_send_file.md)
|
* [`mg_send_file();`](mg_send_file.md)
|
||||||
* [`mg_send_mime_file2();`](mg_send_mime_file2.md)
|
* [`mg_send_mime_file2();`](mg_send_mime_file2.md)
|
||||||
|
@@ -23,7 +23,7 @@ Additional custom header fields can be added as a parameter. Please make sure th
|
|||||||
|
|
||||||
### See Also
|
### See Also
|
||||||
|
|
||||||
* [`mg_get_builtin_mime_type();`](mg_get_builtin_mime_type.md)
|
* [`httplib_get_builtin_mime_type();`](httplib_get_builtin_mime_type.md)
|
||||||
* [`mg_printf();`](mg_printf.md)
|
* [`mg_printf();`](mg_printf.md)
|
||||||
* [`mg_send_file();`](mg_send_file.md)
|
* [`mg_send_file();`](mg_send_file.md)
|
||||||
* [`mg_send_mime_file();`](mg_send_mime_file.md)
|
* [`mg_send_mime_file();`](mg_send_mime_file.md)
|
||||||
|
@@ -803,9 +803,7 @@ typedef void *(*mg_thread_func_t)(void *);
|
|||||||
CIVETWEB_API int mg_start_thread(mg_thread_func_t f, void *p);
|
CIVETWEB_API int mg_start_thread(mg_thread_func_t f, void *p);
|
||||||
|
|
||||||
|
|
||||||
/* Return builtin mime type for the given file name.
|
CIVETWEB_API const char * httplib_get_builtin_mime_type( const char *file_name );
|
||||||
For unrecognized extensions, "text/plain" is returned. */
|
|
||||||
CIVETWEB_API const char *mg_get_builtin_mime_type(const char *file_name);
|
|
||||||
|
|
||||||
|
|
||||||
/* Get text representation of HTTP status code. */
|
/* Get text representation of HTTP status code. */
|
||||||
|
@@ -534,19 +534,19 @@ static const struct {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* const char *mg_get_builtin_mime_type( const char *path );
|
* const char *httplib_get_builtin_mime_type( const char *path );
|
||||||
*
|
*
|
||||||
* The function mg_get_builtin_mime_type() returns the mime type associated
|
* The function httplib_get_builtin_mime_type() returns the mime type
|
||||||
* with the file with a given extension which is passed as a parameter. The
|
* associated with the file with a given extension which is passed as a
|
||||||
* function performs a binary search through the list of MIME types which is
|
* parameter. The function performs a binary search through the list of MIME
|
||||||
* very efficient and only needs 10 steps for 1000 items in the list or 20
|
* types which is very efficient and only needs 10 steps for 1000 items in the
|
||||||
* steps for 1000000 items.
|
* list or 20 steps for 1000000 items.
|
||||||
*
|
*
|
||||||
* If no matching file extension could be found in the list, the default value
|
* If no matching file extension could be found in the list, the default value
|
||||||
* of "text/plain" is returned instead.
|
* of "text/plain" is returned instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *mg_get_builtin_mime_type( const char *path ) {
|
const char *httplib_get_builtin_mime_type( const char *path ) {
|
||||||
|
|
||||||
int start;
|
int start;
|
||||||
int eind;
|
int eind;
|
||||||
@@ -579,7 +579,7 @@ const char *mg_get_builtin_mime_type( const char *path ) {
|
|||||||
|
|
||||||
return "text/plain";
|
return "text/plain";
|
||||||
|
|
||||||
} /* mg_get_builtin_mime_type */
|
} /* httplib_get_builtin_mime_type */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ void XX_httplib_get_mime_type( struct mg_context *ctx, const char *path, struct
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec->ptr = mg_get_builtin_mime_type(path);
|
vec->ptr = httplib_get_builtin_mime_type( path );
|
||||||
vec->len = strlen(vec->ptr);
|
vec->len = strlen( vec->ptr );
|
||||||
|
|
||||||
} /* XX_httplib_get_mime_type */
|
} /* XX_httplib_get_mime_type */
|
||||||
|
@@ -68,13 +68,13 @@ int main( void ) {
|
|||||||
} while ( p1 != NULL && p2 != NULL );
|
} while ( p1 != NULL && p2 != NULL );
|
||||||
|
|
||||||
|
|
||||||
printf( "Mime type van CSV: \"%s\"\n", mg_get_builtin_mime_type( "fiets.CsV" ) );
|
printf( "Mime type of CSV: \"%s\"\n", httplib_get_builtin_mime_type( "car.CsV" ) );
|
||||||
|
|
||||||
for (a=0; a<index; a++) {
|
for (a=0; a<index; a++) {
|
||||||
|
|
||||||
XX_httplib_snprintf( NULL, NULL, buffer, BUFLEN, "filename%s", XX_httplib_builtin_mime_ext( a ) );
|
XX_httplib_snprintf( NULL, NULL, buffer, BUFLEN, "filename%s", XX_httplib_builtin_mime_ext( a ) );
|
||||||
p1 = XX_httplib_builtin_mime_type( a );
|
p1 = XX_httplib_builtin_mime_type( a );
|
||||||
p2 = mg_get_builtin_mime_type( buffer );
|
p2 = httplib_get_builtin_mime_type( buffer );
|
||||||
|
|
||||||
if ( p1 != p2 ) {
|
if ( p1 != p2 ) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user