aboutsummaryrefslogtreecommitdiff
path: root/doc/chapters
diff options
context:
space:
mode:
authorSebastian Gerhardt <sebgerhardt@gmx.net>2008-09-04 14:26:49 +0000
committerSebastian Gerhardt <sebgerhardt@gmx.net>2008-09-04 14:26:49 +0000
commitcd1ab8768da87d6986f6493a72a86b315fdb70d4 (patch)
tree5119c9817faa5b1c589e055735fe106d1749b339 /doc/chapters
parent2b583e7140b8b6a04769e861507ea212b8ac2817 (diff)
downloadlibmicrohttpd-cd1ab8768da87d6986f6493a72a86b315fdb70d4.tar.gz
libmicrohttpd-cd1ab8768da87d6986f6493a72a86b315fdb70d4.zip
some typos in tutorial
Diffstat (limited to 'doc/chapters')
-rw-r--r--doc/chapters/largerpost.inc38
1 files changed, 19 insertions, 19 deletions
diff --git a/doc/chapters/largerpost.inc b/doc/chapters/largerpost.inc
index dd3f9d6f..07e62470 100644
--- a/doc/chapters/largerpost.inc
+++ b/doc/chapters/largerpost.inc
@@ -1,7 +1,7 @@
1--- NOTE: This does not work flawlessly with the beta release because there is 1--- NOTE: This does not work flawlessly with the beta release because there is
2a bug preventing early busy messages from being sent --- 2a bug preventing early busy messages from being sent ---
3 3
4The previous chapter introduced a way to upload data to the server but the developed example program 4The previous chapter introduced a way to upload data to the server, but the developed example program
5has some shortcomings, such as not being able to handle larger chunks of data. In this chapter, we 5has some shortcomings, such as not being able to handle larger chunks of data. In this chapter, we
6are going to discuss a more advanced server program that allows clients to upload a file in order to 6are going to discuss a more advanced server program that allows clients to upload a file in order to
7have it stored on the server's filesystem. The server shall also watch and limit the number of 7have it stored on the server's filesystem. The server shall also watch and limit the number of
@@ -11,24 +11,24 @@ clients concurrently uploading, responding with a proper busy message if necessa
11@heading Prepared answers 11@heading Prepared answers
12We choose to operate the server with the @code{SELECT_INTERNALLY} method. This makes it easier to 12We choose to operate the server with the @code{SELECT_INTERNALLY} method. This makes it easier to
13synchronize the global states at the cost of possible delays for other connections if the processing 13synchronize the global states at the cost of possible delays for other connections if the processing
14of a request is to slow. A variable that needs to be shared for all connections is the total number 14of a request is too slow. One of these variables that needs to be shared for all connections is the
15of clients which are uploading. 15total number of clients that are uploading.
16 16
17@verbatim 17@verbatim
18#define MAXCLIENTS 2 18#define MAXCLIENTS 2
19static unsigned char nr_of_uploading_clients = 0; 19static unsigned char nr_of_uploading_clients = 0;
20@end verbatim 20@end verbatim
21@noindent 21@noindent
22 22
23If there are too many clients uploading, we want the server to respond to all requests with a busy 23If there are too many clients uploading, we want the server to respond to all requests with a busy
24message 24message.
25@verbatim 25@verbatim
26const char* busypage = "<html><body>This server is busy, please try again later.</body></html>"; 26const char* busypage = "<html><body>This server is busy, please try again later.</body></html>";
27@end verbatim 27@end verbatim
28@noindent 28@noindent
29 29
30Otherwise, the server will send a form that informs the user of the current number of uploading clients, 30Otherwise, the server will send a @emph{form} that informs the user of the current number of uploading clients,
31and ask her to pick a file on her local filesystem for uploading. 31and ask her to pick a file on her local filesystem which is to be uploaded.
32@verbatim 32@verbatim
33const char* askpage = "<html><body>\n\ 33const char* askpage = "<html><body>\n\
34 Upload a file, please!<br>\n\ 34 Upload a file, please!<br>\n\
@@ -54,9 +54,9 @@ const char* fileexistspage = "<html><body>This file already exists.</body></html
54@end verbatim 54@end verbatim
55@noindent 55@noindent
56 56
57It would be tolerable to send all these responses undifferentiated with an @code{200 HTTP_OK} 57It would be tolerable to send all these responses undifferentiated with a @code{200 HTTP_OK}
58status code, but in order to improve the @code{HTTP} conformance of our server a bit, we extend the 58status code but in order to improve the @code{HTTP} conformance of our server a bit, we extend the
59@code{send_page} function so that it allows to chose individual status codes. 59@code{send_page} function so that it accepts individual status codes.
60 60
61@verbatim 61@verbatim
62int send_page (struct MHD_Connection *connection, const char* page, int status_code) 62int send_page (struct MHD_Connection *connection, const char* page, int status_code)
@@ -84,7 +84,7 @@ become clear later.
84The decision whether the server is busy or not is made right at the beginning of the connection. To 84The decision whether the server is busy or not is made right at the beginning of the connection. To
85do that at this stage is especially important for @emph{POST} requests because if no response is 85do that at this stage is especially important for @emph{POST} requests because if no response is
86queued at this point, and @code{MHD_YES} returned, @emph{MHD} will not sent any queued messages until 86queued at this point, and @code{MHD_YES} returned, @emph{MHD} will not sent any queued messages until
87a postprocessor has been created and the post iterator was called at least once. 87a postprocessor has been created and the post iterator is called at least once.
88 88
89@verbatim 89@verbatim
90int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, 90int answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url,
@@ -101,7 +101,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const ch
101@noindent 101@noindent
102 102
103If the server is not busy, the @code{connection_info} structure is initialized as usual, with 103If the server is not busy, the @code{connection_info} structure is initialized as usual, with
104an additional filepointer for each connection. 104the addition of a filepointer for each connection.
105 105
106@verbatim 106@verbatim
107 con_info = malloc (sizeof (struct connection_info_struct)); 107 con_info = malloc (sizeof (struct connection_info_struct));
@@ -150,8 +150,8 @@ the structure is initialized to "no error".
150@noindent 150@noindent
151 151
152If the connection handler is called for the second time, @emph{GET} requests will be answered with 152If the connection handler is called for the second time, @emph{GET} requests will be answered with
153the form. We can keep the buffer under function scope because we have asked @emph{MHD} to make its 153the @emph{form}. We can keep the buffer under function scope, because we asked @emph{MHD} to make its
154own copy of it for as long as it needs one. 154own copy of it for as long as it is needed.
155@verbatim 155@verbatim
156 if (0 == strcmp (method, "GET")) 156 if (0 == strcmp (method, "GET"))
157 { 157 {
@@ -191,8 +191,8 @@ constituted no expected request method.
191 191
192 192
193@heading Storing to data 193@heading Storing to data
194Unlike the @code{simplepost.c} example, it is to be expected that post iterator will be called 194Unlike the @code{simplepost.c} example, here it is to be expected that post iterator will be called
195several times now. This means that for any given connection, there might be several concurrent of them, 195several times now. This means that for any given connection (there might be several concurrent of them)
196the posted data has to be written to the correct file. That is why we store a file handle in every 196the posted data has to be written to the correct file. That is why we store a file handle in every
197@code{connection_info}, so that the it is preserved between successive iterations. 197@code{connection_info}, so that the it is preserved between successive iterations.
198@verbatim 198@verbatim
@@ -213,7 +213,7 @@ con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR;
213@end verbatim 213@end verbatim
214@noindent 214@noindent
215 215
216In the "askpage" form, we told the client to label its post data with the "file" key. Anything else 216In the "askpage" @emph{form}, we told the client to label its post data with the "file" key. Anything else
217would be an error. 217would be an error.
218 218
219@verbatim 219@verbatim
@@ -253,7 +253,7 @@ if (size > 0)
253@end verbatim 253@end verbatim
254@noindent 254@noindent
255 255
256If this point has been reached, everything worked flawless for this iteration and the response can 256If this point has been reached, everything worked well for this iteration and the response can
257be set to success again. If the upload has finished, this iterator function will not be called again. 257be set to success again. If the upload has finished, this iterator function will not be called again.
258@verbatim 258@verbatim
259 con_info->answerstring = completepage; 259 con_info->answerstring = completepage;
@@ -299,4 +299,4 @@ This is essentially the whole example @code{largepost.c}.
299@heading Remarks 299@heading Remarks
300Now that the clients are able to create files on the server, security aspects are becoming even more 300Now that the clients are able to create files on the server, security aspects are becoming even more
301important than before. Aside from proper client authentication, the server should always make sure 301important than before. Aside from proper client authentication, the server should always make sure
302explicitly that no files will be written outside a dedicated upload directory. 302explicitly that no files will be created outside of a dedicated upload directory.