215
218
* IN OUT int* timeout_secs; time out
216
219
* OUT int* http_error_code; HTTP error code returned
219
* Get the data on the socket and take actions based on the read data
220
* to modify the parser objects buffer. If an error is reported while
221
* parsing the data, the error code is passed in the http_errr_code
225
223
* UPNP_E_BAD_HTTPMSG
227
************************************************************************/
229
http_RecvMessage( IN SOCKINFO * info,
230
OUT http_parser_t * parser,
231
IN http_method_t request_method,
232
IN OUT int *timeout_secs,
233
OUT int *http_error_code )
225
int http_RecvMessage(
227
OUT http_parser_t *parser,
228
IN http_method_t request_method,
229
IN OUT int *timeout_secs,
230
OUT int *http_error_code)
235
parse_status_t status;
237
xboolean ok_on_close = FALSE;
240
if( request_method == HTTPMETHOD_UNKNOWN ) {
241
parser_request_init( parser );
243
parser_response_init( parser, request_method );
247
num_read = sock_read( info, buf, sizeof( buf ), timeout_secs );
250
status = parser_append( parser, buf, num_read );
252
if( status == PARSE_SUCCESS ) {
253
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
254
"<<< (RECVD) <<<\n%s\n-----------------\n",
255
parser->msg.msg.buf );
256
print_http_headers( &parser->msg );
258
if( parser->content_length >
259
( unsigned int )g_maxContentLength ) {
260
*http_error_code = HTTP_REQ_ENTITY_TOO_LARGE;
261
return UPNP_E_OUTOF_BOUNDS;
265
} else if( status == PARSE_FAILURE ) {
266
*http_error_code = parser->http_error_code;
267
return UPNP_E_BAD_HTTPMSG;
268
} else if( status == PARSE_INCOMPLETE_ENTITY ) {
271
} else if( status == PARSE_CONTINUE_1 ) //Web post request. murari
273
return PARSE_SUCCESS;
275
} else if( num_read == 0 ) {
277
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
278
"<<< (RECVD) <<<\n%s\n-----------------\n",
279
parser->msg.msg.buf );
280
print_http_headers( &parser->msg );
285
*http_error_code = HTTP_BAD_REQUEST; // or response
286
return UPNP_E_BAD_HTTPMSG;
289
*http_error_code = parser->http_error_code;
232
int ret = UPNP_E_SUCCESS;
234
parse_status_t status;
236
xboolean ok_on_close = FALSE;
239
if (request_method == HTTPMETHOD_UNKNOWN) {
240
parser_request_init(parser);
242
parser_response_init(parser, request_method);
246
num_read = sock_read(info, buf, sizeof buf, timeout_secs);
249
status = parser_append(parser, buf, num_read);
250
if (status == PARSE_SUCCESS) {
251
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
252
"<<< (RECVD) <<<\n%s\n-----------------\n",
253
parser->msg.msg.buf );
254
print_http_headers( &parser->msg );
255
if (parser->content_length > (unsigned int)g_maxContentLength) {
256
*http_error_code = HTTP_REQ_ENTITY_TOO_LARGE;
258
ret = UPNP_E_OUTOF_BOUNDS;
264
} else if (status == PARSE_FAILURE) {
265
*http_error_code = parser->http_error_code;
267
ret = UPNP_E_BAD_HTTPMSG;
269
} else if (status == PARSE_INCOMPLETE_ENTITY) {
272
} else if (status == PARSE_CONTINUE_1) {
278
} else if (num_read == 0) {
280
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
281
"<<< (RECVD) <<<\n%s\n-----------------\n",
282
parser->msg.msg.buf );
283
print_http_headers(&parser->msg);
289
*http_error_code = HTTP_BAD_REQUEST; // or response
291
ret = UPNP_E_BAD_HTTPMSG;
295
*http_error_code = parser->http_error_code;
303
if (ret != UPNP_E_SUCCESS) {
304
UpnpPrintf(UPNP_ALL, HTTP, __FILE__, line,
305
"(http_RecvMessage): Error %d, http_error_code = %d.\n",