Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
518a4e8c
Commit
518a4e8c
authored
16 years ago
by
patacongo
Browse files
Options
Downloads
Patches
Plain Diff
More bugfixes
git-svn-id:
svn://svn.code.sf.net/p/nuttx/code/trunk@1646
42af7a65-404d-4744-a932-0658087f49c3
parent
d200d5a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
netutils/webclient/webclient.c
+49
-44
49 additions, 44 deletions
netutils/webclient/webclient.c
with
49 additions
and
44 deletions
netutils/webclient/webclient.c
+
49
−
44
View file @
518a4e8c
...
...
@@ -303,72 +303,77 @@ static inline int wget_parseheaders(struct wget_s *ws)
* we parse it.
*/
if
(
ws
->
line
[
0
]
==
ISO_cr
)
if
(
ndx
>
0
)
/* Should always be true */
{
/* This was the last header line (i.e., and empty "\r\n"), so
* we are done with the headers and proceed with the actual
* data.
*/
if
(
ws
->
line
[
0
]
==
ISO_cr
)
{
/* This was the last header line (i.e., and empty "\r\n"), so
* we are done with the headers and proceed with the actual
* data.
*/
ws
->
state
=
WEBCLIENT_STATE_DATA
;
goto
exit
;
}
ws
->
state
=
WEBCLIENT_STATE_DATA
;
goto
exit
;
}
ws
->
line
[
ndx
]
=
'\0'
;
/* Truncate the trailing \r\n */
/* Check for specific HTTP header fields. */
ws
->
line
[
ndx
-
1
]
=
'\0'
;
#ifdef CONFIG_WEBCLIENT_GETMIMETYPE
if
(
strncasecmp
(
ws
->
line
,
g_httpcontenttype
,
strlen
(
g_httpcontenttype
))
==
0
)
{
/* Found Content-type field. */
/* Check for specific HTTP header fields. */
char
*
dest
=
strchr
(
ws
->
line
,
';'
);
if
(
dest
!=
NULL
)
#ifdef CONFIG_WEBCLIENT_GETMIMETYPE
if
(
strncasecmp
(
ws
->
line
,
g_httpcontenttype
,
strlen
(
g_httpcontenttype
))
==
0
)
{
*
dest
=
0
;
/* Found Content-type field. */
char
*
dest
=
strchr
(
ws
->
line
,
';'
);
if
(
dest
!=
NULL
)
{
*
dest
=
0
;
}
strncpy
(
ws
->
mimetype
,
ws
->
line
+
strlen
(
g_httpcontenttype
),
sizeof
(
ws
->
mimetype
));
}
strncpy
(
ws
->
mimetype
,
ws
->
line
+
strlen
(
g_httpcontenttype
)
-
1
,
sizeof
(
ws
->
mimetype
));
}
else
else
#endif
if
(
strncasecmp
(
ws
->
line
,
g_httplocation
,
strlen
(
g_httplocation
))
==
0
)
{
/* Save a pointer to the location */
if
(
strncasecmp
(
ws
->
line
,
g_httplocation
,
strlen
(
g_httplocation
))
==
0
)
{
/* Save a pointer to the location */
char
*
dest
=
ws
->
line
+
strlen
(
g_httplocation
)
-
1
;
char
*
dest
=
ws
->
line
+
strlen
(
g_httplocation
);
/* Concatenate the hostname */
/* Concatenate the hostname */
if
(
strncmp
(
dest
,
g_httphttp
,
strlen
(
g_httphttp
))
==
0
)
{
for
(
i
=
0
,
dest
+=
7
;
i
<
ws
->
ndx
-
7
;
i
++
,
dest
++
)
if
(
strncmp
(
dest
,
g_httphttp
,
strlen
(
g_httphttp
))
==
0
)
{
if
(
*
dest
=
=
0
||
*
dest
=
=
'/'
||
*
dest
==
' '
||
*
dest
==
':'
)
for
(
i
=
0
,
dest
+
=
7
;
i
<
ws
->
ndx
-
7
;
i
++
,
dest
++
)
{
ws
->
hostname
[
i
]
=
0
;
break
;
}
else
if
(
i
<
CONFIG_NETUTILS_WEBCLIENT_MAXHOSTNAME
-
1
)
{
ws
->
hostname
[
i
]
=
*
dest
;
if
(
*
dest
==
0
||
*
dest
==
'/'
||
*
dest
==
' '
||
*
dest
==
':'
)
{
ws
->
hostname
[
i
]
=
0
;
break
;
}
else
if
(
i
<
CONFIG_NETUTILS_WEBCLIENT_MAXHOSTNAME
-
1
)
{
ws
->
hostname
[
i
]
=
*
dest
;
}
}
}
}
/* Copy the location */
/* Copy the location */
strncpy
(
ws
->
filename
,
dest
,
CONFIG_NETUTILS_WEBCLIENT_MAXFILENAME
-
1
);
strncpy
(
ws
->
filename
,
dest
,
CONFIG_NETUTILS_WEBCLIENT_MAXFILENAME
-
1
);
/* Make sure that everything is NULL terminated */
/* Make sure that everything is NULL terminated */
ws
->
hostname
[
CONFIG_NETUTILS_WEBCLIENT_MAXHOSTNAME
-
1
]
=
'\0'
;
ws
->
filename
[
CONFIG_NETUTILS_WEBCLIENT_MAXFILENAME
-
1
]
=
'\0'
;
nvdbg
(
"New hostname='%s' filename='%s'
\n
"
,
ws
->
hostname
,
ws
->
filename
);
ws
->
hostname
[
CONFIG_NETUTILS_WEBCLIENT_MAXHOSTNAME
-
1
]
=
'\0'
;
ws
->
filename
[
CONFIG_NETUTILS_WEBCLIENT_MAXFILENAME
-
1
]
=
'\0'
;
nvdbg
(
"New hostname='%s' filename='%s'
\n
"
,
ws
->
hostname
,
ws
->
filename
);
}
}
/* We're done parsing, so we reset the
pointer and
start
the
* next line.
/* We're done parsing
this line
, so we reset the
index to the
start
*
of the
next line.
*/
ndx
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment