Sponsored Content
Full Discussion: size of char array in c
Top Forums Programming size of char array in c Post 302142192 by Hitori on Thursday 25th of October 2007 03:04:55 AM
Old 10-25-2007
Quote:
Originally Posted by phani_sree
thank u,
ok but we don't know the value of num_of_bytes value?
actually iam reading from webpage using curl socket.i don't know how much data it amy come.
so please show me the solution
If you read from socket HTTP/1.1 response then you can determine the size of the data from Content-Length header. But be aware of chunked responses, i.e.


Code:
HTTP/1.1 200 OK
Date: Fri, 31 Dec 1999 23:59:59 GMT
Content-Type: text/plain
Transfer-Encoding: chunked

1a; ignore-stuff-here
abcdefghijklmnopqrstuvwxyz
10
1234567890abcdef
0
some-footer: some-value
another-footer: another-value
[blank line here]

what corresponds to

Code:
HTTP/1.1 200 OK
Date: Fri, 31 Dec 1999 23:59:59 GMT
Content-Type: text/plain
Content-Length: 42
some-footer: some-value
another-footer: another-value

abcdefghijklmnopqrstuvwxyz1234567890abcdef


see RFC 2616
 

9 More Discussions You Might Find Interesting

1. Programming

size of a char devices

hi i want to write a simple io-benchmark for raw devices, especially for harddisks, vx-volumes and md-volumes on solaris. is there a unix system call to get the size of the device? the 'stat' system call reports the size for regaular files but not for block or devices. On Solaris the... (2 Replies)
Discussion started by: guenter
2 Replies

2. Programming

char array problem

hello i have a program in C (Unix - SOlaris5.7), and i have the next question: i have a lot of char variable, and i want store their values in a char array. The problem is what i donīt know how to put the char variable's value into the array, and i don`t know how to define the array please... (4 Replies)
Discussion started by: DebianJ
4 Replies

3. Programming

char array

hi, I have variable like, char keyword = "TRANSPARENCY "; while passing this variable to some function, first character of variable becomes null, but rest of characters still exist. Why this happens or something wrong with declaration. Their is no error while compiling & running... (2 Replies)
Discussion started by: avadhani
2 Replies

4. Programming

CHAR Array - stuffed with values - with more size than it holds

Hi All I am simulating a problem in the production where i faced a situation. Please find the following example program which i simulated. #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char str1; (3 Replies)
Discussion started by: dhanamurthy
3 Replies

5. Programming

Passing by value a char array

Hi I am passing or want to pass value of a char array, so that even thoug the called routine is changing the values the calling function should not see the values changed, meaning only copy should be passed Here is the program #include<iostream.h> #include<string.h> void f(char a); int... (5 Replies)
Discussion started by: rkraj
5 Replies

6. Programming

Array of char

I'm doing some coding in C++ Want to have a long empty string like below const char ModMisfit :: DelStr = "\r \r"; However due to the long blank the line is very long. Is there any way to avoid this and keep the... (5 Replies)
Discussion started by: kristinu
5 Replies

7. Programming

help with char pointer array in C

i have an array like #define NUM 8 .... new_socket_fd = accept(socket_fd, (struct sockaddr *) &cli_addr, &client_length); char *items = {"one", "two", "three", "four", "five", "six", "seven", "eight"}; char *item_name_length = {"3", "3", "5", "4", "4", "3", "5", "5"}; ... (1 Reply)
Discussion started by: omega666
1 Replies

8. Programming

char array

cat int.c int main() { unsigned char wwn; wwn=50; wwn=00; wwn=53; wwn=30; wwn=08; wwn=09; wwn=82; wwn=17; printf("WWN: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n ", wwn, wwn, wwn, wwn, wwn,... (8 Replies)
Discussion started by: powyama
8 Replies

9. Programming

Returning char array

I want to return a char array to the main() function, but its returning garbage value. #include<stdio.h> //#include<conio.h> #include<string.h> char* strtrmm(); int main() { char str1,c1; printf("\n Enter the string:"); gets(str1); //strtrmm(str1); printf("%s",strtrmm(str1));... (2 Replies)
Discussion started by: zinat
2 Replies
Mojo::Content(3pm)					User Contributed Perl Documentation					Mojo::Content(3pm)

NAME
Mojo::Content - HTTP 1.1 content base class SYNOPSIS
use Mojo::Base 'Mojo::Content'; DESCRIPTION
Mojo::Content is an abstract base class for HTTP 1.1 content as described in RFC 2616. EVENTS
Mojo::Content can emit the following events. "drain" $content->on(drain => sub { my ($content, $offset) = @_; ... }); Emitted once all data has been written. $content->on(drain => sub { my $content = shift; $content->write_chunk(time); }); "body" $content->on(body => sub { my $content = shift; ... }); Emitted once all headers have been parsed and the body starts. $content->on(body => sub { my $content = shift; $content->auto_upgrade(0) if $content->headers->header('X-No-MultiPart'); }); "read" $content->on(read => sub { my ($content, $chunk) = @_; ... }); Emitted when a new chunk of content arrives. $content->unsubscribe('read'); $content->on(read => sub { my ($content, $chunk) = @_; say "Streaming: $chunk"; }); ATTRIBUTES
Mojo::Content implements the following attributes. "auto_relax" my $relax = $content->auto_relax; $content = $content->auto_relax(1); Try to detect broken web servers and turn on relaxed parsing automatically. "headers" my $headers = $content->headers; $content = $content->headers(Mojo::Headers->new); Content headers, defaults to a Mojo::Headers object. "max_leftover_size" my $size = $content->max_leftover_size; $content = $content->max_leftover_size(1024); Maximum size in bytes of buffer for pipelined HTTP requests, defaults to the value of the "MOJO_MAX_LEFTOVER_SIZE" environment variable or 262144. "relaxed" my $relaxed = $content->relaxed; $content = $content->relaxed(1); Activate relaxed parsing for HTTP 0.9 and responses that are terminated with a connection close. METHODS
Mojo::Content inherits all methods from Mojo::EventEmitter and implements the following new ones. "body_contains" my $success = $content->body_contains('foo bar baz'); Check if content contains a specific string. Meant to be overloaded in a subclass. "body_size" my $size = $content->body_size; Content size in bytes. Meant to be overloaded in a subclass. "boundary" my $boundary = $content->boundary; Extract multipart boundary from "Content-Type" header. "build_body" my $string = $content->build_body; Render whole body. "build_headers" my $string = $content->build_headers; Render all headers. "charset" my $charset = $content->charset; Extract charset from "Content-Type" header. "clone" my $clone = $content->clone; Clone content if possible, otherwise return "undef". "generate_body_chunk" my $chunk = $content->generate_body_chunk(0); Generate dynamic content. "get_body_chunk" my $chunk = $content->get_body_chunk(0); Get a chunk of content starting from a specfic position. Meant to be overloaded in a subclass. "get_header_chunk" my $chunk = $content->get_header_chunk(13); Get a chunk of the headers starting from a specfic position. "has_leftovers" my $success = $content->has_leftovers; Check if there are leftovers. "header_size" my $size = $content->header_size; Size of headers in bytes. "is_chunked" my $success = $content->is_chunked; Check if content is chunked. "is_dynamic" my $success = $content->is_dynamic; Check if content will be dynamically generated, which prevents "clone" from working. "is_finished" my $success = $content->is_finished; Check if parser is finished. "is_multipart" my $false = $content->is_multipart; False. "is_parsing_body" my $success = $content->is_parsing_body; Check if body parsing started yet. "leftovers" my $bytes = $content->leftovers; Get leftover data from content parser. "parse" $content = $content->parse("Content-Length: 12 Hello World!"); Parse content chunk. "parse_body" $content = $content->parse_body("Hi!"); Parse body chunk. "parse_body_once" $content = $content->parse_body_once("Hi!"); Parse body chunk once. "parse_until_body" $content = $content->parse_until_body("Content-Length: 12 Hello World!"); Parse chunk and stop after headers. "progress" my $size = $content->progress; Size of content already received from message in bytes. "write" $content->write('Hello!'); $content->write('Hello!', sub {...}); Write dynamic content non-blocking, the optional drain callback will be invoked once all data has been written. "write_chunk" $content->write_chunk('Hello!'); $content->write_chunk('Hello!', sub {...}); Write dynamic content non-blocking with "chunked" transfer encoding, the optional drain callback will be invoked once all data has been written. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Content(3pm)
All times are GMT -4. The time now is 06:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy