Commit Graph

603 Commits

Author SHA1 Message Date
Adrien Destugues
9bf4e99477 BUrl: IDNA ToUnicode and ToASCII conversions.
* Since DNS are normally restricted to ASCII, the use of UTF-8 in domain
names is implemented using a "punycode" encoding.
* The request to the DNS server must be sent with the ASCII
representation of the domain name, however the Unicode one should be
used for user-visible parts.
* ICU provides an implementation of the conversion, which we use here.
* Conversion is currently done in-place and modifies the BUrl object
(this is similar to UrlEncode/UrlDecode).
* Adjust existing IDN test to make use of these methods. It's passing
now.
2014-10-21 14:43:13 +02:00
Adrien Destugues
06f436b3ac Use strict mode when url-decoding file requests.
We don't want '+' to become a space here.
Fixes #11109.
2014-10-21 11:31:48 +02:00
Adrien Destugues
4f978fe4db BNetBuffer: add some error checks.
The allocation of fImpl can fail, and some methods used it without
checking. Return an error code (or NULL or 0) instead of crashing in
these cases.

Also InitCheck the fInputBuffer in BHttpRequest before trying to use it.

Fixes #11350.
2014-10-18 10:15:06 +02:00
Adrien Destugues
1c0b6a4293 SecureSocket: disable SSL versions 2 and 3
There are known vulnerabilities in those. Everyone should be using TLS
by now.
2014-10-15 16:17:09 +02:00
Oliver Tappe
3006031ac2 Move Geolocation to kits/shared and make it private. 2014-10-02 00:32:48 +02:00
Adrien Destugues
1d38b7a86a Geolocation: avoid static init of BUrl
* Fixes #11290.
2014-09-27 19:20:39 +02:00
Adrien Destugues
be37c44a19 style fix. 2014-09-26 16:16:52 +02:00
Adrien Destugues
2f36873105 UrlRequest: add empty SetTimeout for ease of use.
* Requests that support this can implement it, NetworkRequest does
* Build fix: no need to return status_t.
2014-09-26 15:51:36 +02:00
Adrien Destugues
654ae69aa6 NetworkRequest: add a SetTimeout method. 2014-09-26 15:21:54 +02:00
Adrien Destugues
8a39d53d23 Geolocation: remove leftover print. 2014-09-24 19:01:58 +02:00
Adrien Destugues
80e7d92949 BGeolocation: make it work with the actual API.
* It seems openbmap is using a variation of the API that's not
compatible with what other providers use.
* Fix a ";" instead of "," in the JSON request. We should get a
BJsonBuilder to avoid such silly errors
* Improve indenting of the request to ease readability.
* Parse the latitude and longitude as doubles, not strings.

This was tested against Mozilla Location Services and I get accurate
results (withing a few hundred meters). However I'm not sure how to
share the MLS API key safely so it is used only in Haiku, I will discuss
this with the MLS team.
2014-09-24 18:32:03 +02:00
Adrien Destugues
13f0458896 Add BGeolocation experimental API.
A BGeolocation object can query an online service to get geolocation
and geotagging data:
 * LocateSelf() tries to locate the machine it is running on, by using an
online database of wifi access points
 * Locate() (not yet implemented) searches a BString and converts it to
lat/lon coordinates (reverse geotagging)
 * Name() (not yet implemented) finds a suitable name for the given
coordinates (address, building name, or anything fitting).

The default service used is openbmap.org, which is freely available but
not very accurate. A request has been sent to Mozilla to use MLS
(Mozilla Location Services), which is a bit more accurate but needs an
API key. MLS is used for geolocation on FirefoxOS, for mobile phones
which don't have a GPS, and the data can be contributed by Firefox for
Android or the dedicated MozStumbler app.

Alternatively, Google Maps also provide the service, but wants
people to pay for it. Google Maps data is more accurate as all Android
devices contribute data to it.

All 3 services use the same JSON-based API: we send a list of reachable
Wifi APs (mac address and signal strength), and we get lattitude and
longitude information, and possibly extra data which will currently be
unused.

This can be used to implement HTML5 geolocation with reasonably accurate
results, but it can also be used in other places. For example
FirstBootPrompt could try to guess a list of most likely languages and
keyboard layouts from it (if wifi is working at install time, that is).
2014-09-23 16:37:59 +02:00
Adrien Destugues
7603710e9a Style fixes. 2014-09-16 21:39:53 +02:00
Adrien Destugues
21f8e588da Optimize BUrl copy.
BUrl is passed by value in many places, and we should make sure this is
as efficient as possible. There is little point in initializing all the
strings then overwriting them by using the copy constructor, when we can
set them directly.
2014-09-16 15:30:01 +02:00
Adrien Destugues
c98378e51a Add HTTP proxy support.
* Move default context management to BUrlRequest since some code
(including the testsuite) bypass the BUrlProtocolRoster.
* Introduce proxy host and port in BUrlContext
* Have BHttpRequest use the proxy when making requests
2014-09-15 14:24:37 +02:00
Adrien Destugues
6e38076e81 Libnetapi: fix abortion of file requests.
* We didn't wait for the thread to terminate, so the thread could use
the object after deletion.
2014-09-04 11:29:40 +02:00
Adrien Destugues
12cd565ad7 SecureSocket: add OpenSSL locking.
This shoiuld make OpenSSL more thread safe and help with the random
network related crashes in Web+ (and anything else using SecureSocket
with more than one thread).
2014-09-01 09:54:46 +02:00
Oliver Tappe
87e8603d9f Merge branch 'gcc_syslibs'
* From now on, the gcc-specific system libraries (libgcc, libsupc++ and
  libstdc++) are provided by separate packages built along with gcc:
  - gcc_syslibs contains the shared libraries (libgcc_s.so, libsupc++.so and
    libstdc++.so)
  - gcc_syslibs_devel contains the static libraries and both c++ and gcc
    headers
  The shared libraries now make proper use of symbol versioning and there
  are version-specific symlinks
* The buildsystem has been adjusted to no longer use the libraries and
  headers from the cross-compiler, but use the ones provided by the
  above-mentioned packages. The only exception is that the 32-bit libraries
  required for the bootloader of the x86_64 architecture are still taken
  from the cross-compiler.
2014-08-13 13:50:29 +02:00
Oliver Tappe
220d040227 Use libstdc++, libsupc++ and libgcc from gcc_syslibs.
* Instead of faking libstdc++.so from libstdc++.a, use libstdc++.so
  from the gcc_syslibs build feature for everything except x86_gcc2.
* Use libgcc_s.so from the gcc_syslibs build feature for everything but
  x86_gcc2 (which still carries libgcc as part of libroot.so).
* Drop filtering of libgcc objects for libroot, as that is no longer
  necessary since we're only using libgcc-as-single-object for libroot
  with x86_gcc2, where the filtered object file doesn't exist. Should
  the objects that used to be filtered cause any problems as part of
  libgcc_s.so, we can always filter them as part of the gcc build.
* Use libsupc++.so from the gcc_syslibs build feature for everything but
  x86_gcc2.
* Adjust all Jamfiles accordingly.
* Deactivate building of faked libstdc++.so for non-x86-gcc2. For
  x86_gcc2, we still build libstdc++.so from the sources in the Haiku
  source tree as part of the Haiku build .
* Put gcc_syslibs package onto the image, when needed.
2014-08-13 13:32:44 +02:00
François Revol
a898bb9032 gopher: Resolve TODO 2014-08-11 15:26:43 +02:00
Jérôme Duval
3aeed6607c include strings.h where appriopriate...
instead or additionally to string.h, in preparation for functions move.
* moves str[n]casecmp() functions and others to strings.h.
* strings.h doesn't include string.h anymore.
* this solves #10949
2014-08-08 22:40:37 +02:00
Adrien Destugues
7bc2acc216 UrlRequest: fix race condition
* The thread could set fRunning to false before the caller had set it to
true, leading to a stalled request.
* Happened easily when testing "data" requests, which are fast since no
I/O is involved.
* Possibly also helps with stalled redirects on Google search I've been
seeing for some time.
2014-08-04 16:54:54 +02:00
Adrien Destugues
a4e5af66f1 Make URL decoding even more solid.
* Thanks to korli for pointing remaining issues.
2014-08-04 16:52:40 +02:00
Adrien Destugues
781c9f2a8f Data URIs: don't decodewith invalid length.. 2014-08-04 16:51:49 +02:00
Adrien Destugues
89b4e98a8f Move signal hack to BNetworkRequest
* This is used to unlock sockets when a read is pending after a close
* It is not needed on requests that don't use a socket.
2014-08-04 16:25:48 +02:00
Adrien Destugues
2f9b187497 Factor out a BNetworkRequest
* Shares common behavior between the Gopher and HTTP request handlers.
* Most of this can be used when implemeting other protocols.
2014-08-04 15:59:53 +02:00
Adrien Destugues
bcd6a67bc0 Don't advertise deflate compression support.
There is some misunderstanding on what the "deflate" is, and we can't
reliably decode it in all cases. So, don't advertise support for it and
let servers use gzip (or no compression) instead.

Fixes #11093
2014-08-04 14:32:06 +02:00
Adrien Destugues
6bd0ac9489 Data URLs: parse the whole URL, not just the path.
The RFC for Data URLs specifies a nonstandard format, and because of
this it doesn't support queries and fragments. This allows the use of
the # and ? characters in the URL data. We didn't handle this properly,
which would lead to truncated data.
2014-08-01 09:38:28 +02:00
Adrien Destugues
eec762686b Safer URL decoding.
Some URLs may use the % character for other purposes than URL-encoding
(this is seen in some data URLs). Make sure we parse that properly, and
avoid a possible out of bounds access if the percent char is near the
end of the string.
2014-08-01 09:38:26 +02:00
François Revol
35edaf281f gopher: Fix for 0-length path
This is the case for urls like gopher://gophernicus.org
(without trailing /), which ended up being downloaded instead of
displayed.
2014-07-30 11:20:56 +02:00
François Revol
44a4999b89 gopher: Add TODOs 2014-07-28 22:01:49 +02:00
François Revol
80be7c9d8f gopher: Change 'd' type items to generic documents
Gophernicus uses it for PostScript as well.
2014-07-28 21:53:51 +02:00
François Revol
b8be186720 gopher: Handle errors from Gophernicus
It sends them as plain text instead of gopher directory
when it doesn't find something...
2014-07-28 20:26:47 +02:00
François Revol
e243a03476 gopher: return an error on resource not found 2014-07-28 19:15:16 +02:00
François Revol
111d695ac0 gopher: Use a BStackOrHeapArray as temporary buffer
And move it out of the loop, no need to construct it at
each iteration anyway.
2014-07-28 19:04:13 +02:00
François Revol
579f95647d gopher: (disabled) controls and size attributes on audio/video
Currently those crash WebPositive when enabled.
2014-07-28 18:34:50 +02:00
Adrien Destugues
a1cce97050 HttpRequest: more small fixes and cleanups
* Remove unneeded field fOutputHeaders and convert it to a local for the
only method that uses it,
* Don't return EOVERFLOW when flushing data from ZLib (the ZLib
decompressor returns this, but zlib docs states that this is NOT an
error condition).
* Replace unneeded temporary BNetBuffer of fixed size with BStackOrHeapArray.
2014-07-28 15:02:17 +02:00
Adrien Destugues
021ebc2f8c Add the port to the HTTP Host header when needed.
* When the port is not the default one, it must be added to the "Host"
header so the server knows what we're connecting to.

Fixes #11070.
2014-07-28 15:02:13 +02:00
François Revol
948a1bb3ce Add identifier (device.node) to the EPLF listing
Probably not used by WebKit either...
2014-07-27 23:17:14 +02:00
François Revol
9535708ba4 Add Unix permission bits to the EPLF listing
As per http://cr.yp.to/ftp/list/eplf.html

Really just for completeness, not even sure Webkit will use it.
2014-07-27 23:17:11 +02:00
François Revol
cb85a59325 Typo: EPLF, not EPFL, we're not in Lausanne ;-) 2014-07-27 23:17:08 +02:00
François Revol
ad3d3335df Fix gopher search forms
Now searching for haiku on Veronica 2 leads to:
gopher://gopher.floodgap.com/7/v2/vs?haiku
2014-07-26 23:55:02 +02:00
François Revol
e95d0f00ce gopher: Set a default MIME type to force downloading 2014-07-26 01:45:40 +02:00
François Revol
cf2bf30633 gopher: Add TODOs 2014-07-26 01:45:16 +02:00
François Revol
0716bfd63c gopher: remove debug printfs 2014-07-26 01:44:54 +02:00
François Revol
6983b35de5 gopher: Add a stylesheet
Modified version from my attempt at adding gopher to NetSurf.
2014-07-26 01:44:31 +02:00
François Revol
ec0e815354 gopher: Handle audio and video types, add a default case 2014-07-26 01:44:09 +02:00
François Revol
0e48c9aecd gopher: Handle some more item types 2014-07-26 01:43:45 +02:00
François Revol
f74e08fca8 gopher: Handle info resources and add proper title
We now create a proper title from the error message, or
the TITLE resource if present.
2014-07-26 01:43:22 +02:00
François Revol
2e8b8fd046 gopher: Handle binary, directory and error types 2014-07-26 01:42:59 +02:00
François Revol
0c1a4ebf8b Preliminary support for Gopher
Currently parses information and text items and retrives files.
2014-07-26 01:42:36 +02:00
Adrien Destugues
6be2152bc4 libbind: allow underscores in domain names
As discussed in http://www.freelists.org/post/haiku-development/Proposal-adding-nochecknames-to-resolvconf-by-default

The underscore is handled like the hyphen, that is, it can only be in
the middle of a word. "a_b.com" is valid, but "a_.com" and "_a.com" are
not.

Patch is from http://lists.freebsd.org/pipermail/freebsd-arch/2003-March/000071.html
2014-07-22 18:08:24 +02:00
Adrien Destugues
807bd20a8f Allocate the default UrlContext as a BReferenceable
BUrlContext now inherits BReferenceable to make it easier to handle the
context lifespan. Make the default context an always-retained reference
to match this.

No functional change in normal conditions, however this avoids an assert
when BReferenceable is built in debug mode.
2014-07-22 17:27:50 +02:00
Adrien Destugues
6a13b12a9b Write all HTTP headers to the socket in one go.
We don't have support for TCP_CORK, which would let the kernel handle
this, so this resulted in lots of very small packets being sent over the
network. Besides the performance issues, this confused aliceadsl.fr HTTP
server and prevented logging in to their website.

Fixes #10556.
2014-07-21 17:26:15 +02:00
Adrien Destugues
9f7d29b05e Fix two problems with chunked gzipped HTTP replies.
* receiveEnd is set in a different place in case of chunked transfers,
which would cause the decompressor to never be flushed.
* In the case of chunked transfers, we call Flush() without any input
data (to flush only whatever is remaining in the decompression buffer).
This causes ZLib to return Z_BUF_ERROR which is translated to
B_BUFFER_OVERFLOW. This is a non-fatal error and is expected behavior in
that case. Don't handle this as an error, and do use the extracted data.

Fixes various cases of missing the last chunk of a page (pastie.org,
Google search results, and more).
2014-07-21 11:49:42 +02:00
Adrien Destugues
92dd9f7360 Style fixes, no functional changes. 2014-07-16 17:57:47 +02:00
Adrien Destugues
3528905be6 Parse multiple HTTP at once
Instead of relying on the global protocol loop to call _ParseHeaders
once for each header, extract as much as possible from the current
buffer.

This saves memory, avoids useless operations on the socket and various
processing steps, and fixes #10245.

Also improve the handling of 0-size requests to make sure they terminate
properly.
2014-07-16 17:34:31 +02:00
Puck Meerburg
d32cb23734 Fix Coverity bug 603941: Negative array index read
Signed-off-by: Philippe Saint-Pierre <stpere@gmail.com>
2014-07-15 15:14:56 -04:00
Ingo Weinhold
b04949711d BUrl::IsValid(): Replace with a slightly better dummy impl 2014-07-03 17:39:59 +02:00
Ingo Weinhold
72f6b787cf BUrl: Add missing functionality from support kit BUrl 2014-07-03 17:39:59 +02:00
Ingo Weinhold
2573655b79 Revert "Revert "HttpRequest: support gzip and deflate compression.""
This reverts commit 256080b112.

With the following changes:
* Adjusted to the BZlibCompressionAlgorithm API.
* Add some error handling.
2014-07-03 17:39:58 +02:00
Ingo Weinhold
c99f294eb0 BNetBuffer: Restore semantics after DynamicBuffer -> BDataIO 2014-07-03 17:39:58 +02:00
Ingo Weinhold
25d34313d0 DynamicBuffer::Read(): Small optimization (skip 0 case) 2014-07-03 17:39:58 +02:00
Ingo Weinhold
6926863e37 DynamicBuffer::Write(): Fix return type and semantics 2014-07-03 17:39:58 +02:00
Ingo Weinhold
739f15e144 Revert "Revert "DynamicBuffer: implement BDataIO""
This reverts commit 747b401e87.
2014-07-03 17:39:57 +02:00
Adrien Destugues
158ae74373 Escape reserved characters when converting paths to urls
* Introduce and use BUrl::BUrl(const BPath&)
* The path is url-encoded, and the protocol is set to "file"

Fixes #10964.
2014-06-25 10:45:03 +02:00
Ingo Weinhold
747b401e87 Revert "DynamicBuffer: implement BDataIO"
This reverts commit 36b1f55a18.
2014-06-18 22:13:39 +02:00
Ingo Weinhold
256080b112 Revert "HttpRequest: support gzip and deflate compression."
This reverts commit c3d0dd7a5e.

Conflicts:
	src/kits/network/libnetapi/HttpRequest.cpp
	src/kits/network/libnetapi/Jamfile
2014-06-18 22:13:39 +02:00
Ingo Weinhold
a05da9f4b2 Revert "...and also fix a mismatched prototype"
This reverts commit 6555120f3b.
2014-06-18 22:13:38 +02:00
Ingo Weinhold
f256bccc66 Revert "Fix zlib-dependency in libnetapi."
This reverts commit 6b6ff33d60.
2014-06-18 22:13:36 +02:00
Adrien Destugues
895fa41e0b Make handling of Http Authentication thread safe
* Each BHttpAuthentication object is locked on all field accesses,
* They are owned by the BUrlContext and never deleted, so there is no
need for reference-counting them,
* The BUrlContext itself is now reference counted, and all BUrlRequests
hold a reference to it.

This makes sure using the BHttpAuthentication objects from requests is
thread-safe.
2014-06-11 14:11:01 +02:00
Adrien Destugues
463ffbfde4 First steps towards cookie jar thread-safety
* Change the semantics of the iterators copy constructor and assignment
operator: they now return a new iterator for the same cookie jar (and
same url for the UrlIterator). They don't try to point to the same
position as the copied iterator. The only purpose of these is to write
code such as:

Iterator it = jar.GetIterator();

so having a full copy isn't that useful.

* The per-domain cookie lists are now protected with a read-write lock.
The iterators retain a read lock while they are handling cookies from
that list. They get a write lock when doing Remove. Adding a cookie to
the jar also gets the write lock for the matching list

* Fix a memory leak when adding a new domain-list to the jar failed

* Simplify the declaration of the PrivateHashMap type (it would be
even simpler if HashMap was a public API)

* The domain hashmap is now a SynchronizedHashMap. It is locked as long
as an Iterator or UrlIterator exists, which may be a problem as these
are public APIs. Writing safe iterators for an hashmap with concurrent
accesses is not easy, so the API could be modified to return a list of
domains and a list of cookies for a given domain or URL instead. This
would suit the intended uses just as well.

* The jar now store const cookies, so there is no need to lock them for
access/modification. Updating a cookie is done by replacing it with
another one in the jar (with the same domain and value). There is still
the problem of deleting a cookie while other threads may still access
it, this will be fixed by making cookies BReferenceable.
2014-06-11 12:59:33 +02:00
Adrien Destugues
0e79d0efbc Disable tracing unless built in debug mode. 2014-06-09 14:12:56 +02:00
Adrien Destugues
1cbab031fd More relaxing of cookie-setting rules
* Allow non-secure page to set (but not read) secure cookies
* Allow pages to set cookies for subdomains (but not access them)
2014-06-09 11:17:49 +02:00
Adrien Destugues
d888718621 HttpTime: don't try to parse timezone
* Cookies sometimes come with the UTC timezone, or no tz info at all.
* No other timezone seems to be used

This allows better matching of cookies which would otherwise be kept
only as session cookies.
2014-06-09 11:10:19 +02:00
Adrien Destugues
f7e7eeba4a Limit cookie value size to 4096 bytes.
Too big cookies will make most web servers reject requests.
2014-06-09 08:50:29 +02:00
Adrien Destugues
550f5b1c95 Fix some issues detected by the testsuite
* An empty "expires" field results in a session cookie, rather than
rejecting the cookie altogether
* A page can set a cookie it is not allowed to access (for example in a
subdirectory of where the page is located). Separate IsValidForUrl and
_CanBeSetFromUrl to perform the appropriate checks in each case.
* Limit cookie path to 4096 characters. As a result of the previous
change, a page would be allowed to set a cookie with an aribrarily long
subpath, wasting disk space and RAM by growing hte cookie jar.
* Don't allow path with . or .. elements. These are a source of
confusion and are not needed.
* Reset the cookie fields when parsing failed. This does not matter when
using the cookie jar, but is useful when working directly with
BNetworkCookie.
2014-06-06 16:53:50 +02:00
Adrien Destugues
fed9b96e26 Better handling of parse errors in HttpTime
strptime can return non-NULL values even if it only parsed part of the
string. This was sometimes making us use the wrong format. Now we try
all formats and checks how much of the string strptime managed to parse.
We stop when it has parsed a big enough part of it.
2014-06-06 16:49:11 +02:00
Adrien Destugues
6ac7ba848b Sort cookies by path length (longest first)
* This makes sure the most specific cookies are sent first, matching
what other browsers do.
2014-06-06 16:48:15 +02:00
Adrien Destugues
4e14963b73 CID 1108421: BUrl constructor missing initializers. 2014-06-06 08:04:16 +02:00
Stephan Aßmus
5eba63a680 UrlContext: Improved comment 2014-06-06 00:23:47 +02:00
Stephan Aßmus
cb1a99c5f0 HttpHeaders: Small code refactorings
Also check BList::Add() for success when adding a BHttpHeader.
2014-06-06 00:23:47 +02:00
Stephan Aßmus
79852c5551 HttpHeaders: Check assigning self in operator=() 2014-06-06 00:23:46 +02:00
Stephan Aßmus
16b8886a59 HttpAuthentication: Check LockBuffer() success...
... in _H() MD5 digest method. Thanks to axeld
for the suggestion.
2014-06-05 21:43:35 +02:00
Stephan Aßmus
258817720c HttpAuthentication: improvements and fixes
* BString::CopyInfo() takes length as second
   parameter, not the end-offset. This bug didn't
   have any effect, since BString clamps the length.
 * ',' is a comma, ':' is a colon.
 * When parsing "additionalData" in the loop for
   name=value pairs, an empty name is not useful,
   continue the loop early.
 * "value" may have the length 0, accessing it
   with value[0] would not lead to an access violation,
   since it just reads the terminating zero (I think),
   but it's nicer if the code makes it clear that
   value being empty is considered.
 * _H() was using a static buffer, in a heavily
   multi-threaded situation. I don't think this was
   healthy.
 * Implement the proposed optimization of using
   BString::LockBuffer(). Appending one char at a time
   is really bad for peformance. The Base64 encoding/decoding
   should really be rewritten as well for similar reasons.
2014-06-05 00:01:13 +02:00
Adrien Destugues
cd805f6793 Remove some redundant fields
These were getting out of sync and causing trouble, and they are easy to
compute from existing information.

Fixes some problems detected by the testsuite where the user/password or
the host would sometime disappear from the URL.
2014-06-04 11:56:23 +02:00
Adrien Destugues
b5bde4ad81 Fix bugs identified by the testsuites
* Handle resolving . and .. in path properly
* Make the subtle distinction between empty and unset for the authority,
fragment and query.
2014-06-04 10:36:10 +02:00
Adrien Destugues
e29e0a0d2a Fix Url relative constructor.
Actually get the query from the base URL.
2014-06-04 08:22:13 +02:00
Oliver Tappe
6b6ff33d60 Fix zlib-dependency in libnetapi.
* Fix copy-'n'paste bug that resulted in the zlib.h dependency being
  added to no source file at all.
2014-05-24 20:26:41 +02:00
Jessica Hamilton
194ce33d65 DynamicBuffer: remove unneeded size check. CID 604168. 2014-05-08 16:41:14 +12:00
Jessica Hamilton
41a9299bb5 BNetEndPoint: fix signedness issues. CID 604169. 2014-05-08 13:48:51 +12:00
Adrien Destugues
4991d3fb52 Fix build. 2014-04-12 09:32:43 +02:00
Adrien Destugues
cfc4b62367 Network Kit: Prepare for HTTP range requests
* The DataReceived hook gets a position argument, making it possible for
listeners to handle out-of-order data (from two range requests at
different positions, for example)
* Adjust HaikuDepot (only user of the API in our sources)
* Add a copy constructor to HTTPRequest that copies the relevant
parameters from an existing request. Makes it easy to repeat a request
with a different range. Could be useful for restarting downloads, or
paralellizing them.
* Add SetRangeStart, SetRangeEnd calls to HTTPRequest, no implementation
yet. I'm putting all the API changes in this commit as it needs to be
synced with a matching haikuwebkit release.
* All archs must update to HaikuWebkit 1.3.0. Previous versions are
broken by this.
2014-04-12 08:57:26 +02:00
Adrien Destugues
f325986993 FileRequest: identify unknown files.
* WebKit testsuite relies on the MIME types being correct, so when the
file doesn't have one, try to identify it.
* May be useful for other apps using FileRequest, anyway.
2014-04-10 08:51:00 +02:00
Adrien Destugues
a8d8e823ea HttpRequest: handle 302 and 307 redirects.
* Makes jamendo.com player work, as their soundfiles are behind a
temporary redirect for load balancing.
2014-04-10 08:50:59 +02:00
Adrien Destugues
943b310c90 Data URLs: fix size computation.
The decoded data is 3/4 the size of base64 encoded, not 4/3.
2014-03-31 09:59:12 +02:00
Oliver Tappe
2e61b6dd1d Adjust libnetwork.so to no longer depend on libbe.so.
* Libbe is not available when cross-building the *_bootstrap packages,
  so no libnetwork could not be used either, which made building 
  anything network-related impossible.
* The only code in libnetwork that requires libbe is the notification,
  so I moved that over to libbnetapi. Non-C++ applications can't use
  the notification calls anyway, as their interface is C++-only.
2014-03-02 21:55:25 +01:00
Adrien Destugues
87400ed1de Use local time when computing max-age expiration
BDateTime.SetTime_t expects its parameter to be in local time.
2014-03-01 09:16:33 +01:00
Julian Harnath
d10ecc2c41 Style fix: add parameter name
* As pointed out by Axel.
2014-02-22 13:51:55 +00:00
Julian Harnath
c99d7ea45c Fix double-free crash in BSecureSocket when cert. verification fails
* BSecureSocket::CertificateVerificationFailed() took a BCertificate
  instance by value as parameter.
  BCertificate deletes internal data in its destructor. Passing an
  object by value creates a copy, so the copy attempted to delete
  the internal data again during its destruction.
  This caused mail_daemon to crash here when it came across a failed
  certificate.

* Fix: pass BCertificate object as reference.
2014-02-22 02:09:55 +00:00
Adrien Destugues
67d06c8802 Httprequest: remove "chunked" from http accept-encoding.
This is useless, chunked support is mandatory in HTTP1.1, and it's not a
content-encoding, but a transfer-encoding, so accept-encoding wouldn't
help anyway.
2014-02-17 14:48:57 +01:00
Stephan Aßmus
3e2e0e63cd BHttpRequest: Improve cookie string building loop...
... to avoid some checks. Does it make the code more readable? Not
that it was hard to follow before.
2014-02-13 12:27:33 +01:00
Stephan Aßmus
1514eb3753 BHttpRequest: More elegant way to build cookieString 2014-02-13 10:21:37 +01:00
Stephan Aßmus
6aeaeade6b BHttpRequest: Small fixes
* Allow BString to find a semicolon more efficiently.
 * Replace a dynamic stack allocated array with BStackOrHeapArray
   in one more place.
2014-02-13 10:12:55 +01:00
Adrien Destugues
3e358c1fca HttpRequest: use BStackOrHeapArray
Sometimes we get enough bytes at once from the connection to trigger a
stack overflow. Allocate memory on the heap instead.
2014-02-13 09:36:40 +01:00
Adrien Destugues
6555120f3b ...and also fix a mismatched prototype
gcc2 doesn't seem to notice.
2014-02-11 13:26:32 +01:00
Adrien Destugues
c3d0dd7a5e HttpRequest: support gzip and deflate compression.
* Use the ZlibDecompressor to decompress the data
* Advertise support in accept-encoding

This should make web browsing feel even faster on wesites that support
these compresion schemes. It also fixes some websites (www.ru,
rainloop.net, ...) that serve gzipped resources even to browser not
supporting it.
2014-02-11 12:06:42 +01:00
Adrien Destugues
36b1f55a18 DynamicBuffer: implement BDataIO
This makes it possible to use it with the ZlibDecompressor.
2014-02-11 12:06:41 +01:00
Adrien Destugues
35480631f2 Fix various issues with cookie time.
* This is more tricky than it looks.
* We probably want easier conversions from struct tm to BDateTime, and
direct parsing/formating there.
2014-01-23 19:24:34 +01:00
Adrien Destugues
afdca74d9b Make signal handler static
We don't want this method to be exposed in the global namespace!
Also add a note about removing this signal-based solution when our
close() method can be interrupted in other ways.

thanks axel for watching!
2014-01-23 17:23:29 +01:00
Adrien Destugues
d417133ed2 Fix cookies with far expiration date.
Some websites set cookies expiring in the (not so) far future, after year 2038.
So, using time_t to store the cookie expiration date won't do. Use the
BDateTime class instead.

This makes goodsearch.com login work again (#10460).
2014-01-23 17:22:46 +01:00
Adrien Destugues
281727261d urlRequest: interrupt syscalls using a signal
Sometimes an HTTP request would get stuck in a call to connect(). While
our read() and write() implementations are interrupted if you close()
the socket, our connect() isn't. It would nonetheless abort the
connection process, and connect would stay blocked for quite a long
time.

When navigating away from a page, WebKit closes all pending connections,
and in our network backend this also means freeing the request object.
But, the destructor can't be called until the thread has stopped
running, to ensure proper cleanup.

Avoid the lockup in connect by sending a signal (SIGUSR1) to the thread
we want to unlock. This interrupts the syscall, and the thread exits
immediately.
2014-01-23 16:01:39 +01:00
Stephan Aßmus
d5c2ed6b14 FileRequest: Better error handling for size mismatches 2014-01-23 10:20:22 +01:00
Stephan Aßmus
084a160655 FileRequest: Fix transfer error detection not working. CID 1162764 2014-01-22 22:23:31 +01:00
Stephan Aßmus
840aeab5b9 NetEndpoint: Don't forget to close socket in error case. CID 1162792 2014-01-22 17:41:52 +01:00
Stephan Aßmus
dae0b385cf DataRequest: Don't leak buffer in error case. CID 1162796 2014-01-22 17:41:52 +01:00
Stephan Aßmus
59246cf737 HttpRequest: Apparently fContext can be NULL. CID 1162798 2014-01-22 17:41:51 +01:00
Adrien Destugues
7e433e7cad FileRequest: set the mime type early.
WebKit may use the MIME type during incremental loading, so we better
set it before we start feeding the data.
2014-01-19 12:09:52 +01:00
Adrien Destugues
32da3d9dae Cookies: avoid timezone confusion
Cookies date are always in GMT time. Using mktime wrongly converts them
as local time instead. This would lead to cookies expiring too early or
too late.
2014-01-19 12:09:51 +01:00
Adrien Destugues
ab390d3af3 Style fixes and allocation checks 2014-01-17 15:08:57 +01:00
Adrien Destugues
9e9ccf69c0 Yet anoter noSSL build fix. 2014-01-17 12:13:27 +01:00
Adrien Destugues
76b3c7f420 More noSSL build fixes. 2014-01-17 11:21:13 +01:00
Adrien Destugues
e395fc4f3b NetworkCookieJar: use-after-free, memcpy overwrite
* Add some tracing, std::nothrow and null checks
* The HashString class doesn't like SetTo being called with a substring
of the current key, so use a copy of it instead.

Fixes #6667.
2014-01-16 16:54:51 +01:00
Adrien Destugues
547c1486ff Add some missing std::nothrow
... and allocation failure checks.
2014-01-16 13:29:15 +01:00
Adrien Destugues
b70c72a692 Fix concurrency issues in BSecureSocket
* Use pthread_once to initialize the SSL context once, in a thread-safe
way.
* Do not delete the BIO immediately when closing a connexion, instead
delay this to the destructor. This makes sure the protocol loop is done
running when we do that.
* Instead of creating a new BIO when we reconnect an already used
connection, create the BIO upfront, and reuse it with the new file
descriptor.
* Fix a memory leak: the SSL struct from OpenSSL was never freed, only
the BIO was.

Fixes #10414.
2014-01-16 11:25:47 +01:00
Adrien Destugues
67af469ef0 Fix time_t/bigtime_t mixup.
Thanks stippi for noticing!
2014-01-16 09:41:01 +01:00
Adrien Destugues
3db3864644 Fix crash when trying to open a non-existing file. 2014-01-16 09:30:13 +01:00
Adrien Destugues
385a7d89b7 More style fixes. 2014-01-16 09:30:12 +01:00
Adrien Destugues
159d1fb69a Style fixes, build fix with OpenSSL disabled. 2014-01-15 23:32:10 +01:00
Adrien Destugues
00b65b2d7b FileRequest: multiple fixes
* Don't crash when opening a symlink, traverse it instead.
* Add a ".." entry to navigate to the parent folder
* Set the encoding to utf-8 in the MIME header, but this doesn't seem to
work.
2014-01-15 20:20:58 +01:00
Adrien Destugues
4e4396fa46 Fix build. 2014-01-15 17:52:39 +01:00
Adrien Destugues
5ebdc79955 SecureSocket: add some certificate support
* Instead of creating an OpenSSL context ofor each socket, use a global
one and initialize it lazily when the first SecureSocket is created
* Load the certificates from our certificate list so SSL certificates
sent by servers can be validated.
* Add a callback for signalling that certificate validation failed, the
default implementation proceeds with the connection anyway (to keep the
old behavior).
* Introduce BCertificate class, that provides some information about a
certificate. Currently it's only used by the callback mentionned above,
but it will be possible to get the leaf certificate for the connection
after it's established.

Review of the API and implementation is welcome, before I start making
use of this in HttpRequest and WebKit to allow the user to accept new
certificates.
2014-01-15 17:45:21 +01:00
Adrien Destugues
9ab54f9475 Filerequest: UrlDecode() the request.
Makes things work even if the filename has some URL-disallowed
characters (spaces, utf-8, or otherwise).
2014-01-13 09:18:42 +01:00
Adrien Destugues
b3cc244542 Simplify cookie string-ification code. 2014-01-13 09:05:19 +01:00
Adrien Destugues
3d864cd870 Remove B_PROT_* and related code
Use standard error codes instead.
This allows using error code returned by the underlying functions
directly, and makes it possible to use strerror for debugging. So, we
can also remove StatusString() from the various *Request classes.
2014-01-13 08:05:32 +01:00
Adrien Destugues
5e9a96156d FileRequest: style fixes
Pointed out by axeld, stippi and waddlesplash. Thanks for watching.
2014-01-13 08:05:30 +01:00
Adrien Destugues
090ba6d06b FileRequest: implement directory listings.
Use the EPFL (Easily Parsed File Listing) format. This is one of the
formats that WebKit allows for directory listings, and it's easily
parsed and generated.
2014-01-10 15:32:09 +01:00
Adrien Destugues
5bdd4157d3 SecureSocket: avoid crash on close
Deleting the BIO while it's still waiting on a read() in another thread
will lead to a crash when the socket is eventually closed. Close the
socket first, so the read() is unlocked, then safely delete the BIO.
2014-01-06 12:48:46 +01:00
Murai Takashi
7727da7d3d Fix mismatching allocation and deallocation 2014-01-03 13:57:03 +01:00
Adrien Destugues
5b53e2e516 HttpRequest: close the connection on Stop()
When calling Stop(), we expect the request thread to exit as soon as
possible. Closing the connection unlocks it from any blocking read() or
write(), avoiding some lockup situations.
2014-01-02 08:38:03 +01:00
Rene Gollent
2d768aeb6f libnetwork: Fix 64-bit debug build. 2013-12-13 17:54:07 -05:00
Adrien Destugues
07d157db54 BHttpRequest::Result() returns a BUrlResult&.
This overrides BUrlRequest::Result. The returned reference points to a
BHttpResult and can be cast by callers.
2013-12-11 17:50:20 +01:00
Adrien Destugues
824dd0a834 Reintroduce BUrlResult and add BDataRequest
* BUrlResult is back, with ContentType and Length methods.
* BHttpResult subclasses it and use HTTP header fields to implement
those
* Introduce BDataRequest for "data" URIs. These embed the data inside
the URI, either as plaintext or base64 encoded.
2013-12-11 17:29:25 +01:00
Adrien Destugues
f36e1414b7 Cookie Jar: allow setting cookies on "file" URLs.
* These are shared with HTTP cookies set for localhost. We probably want
to split them apart later on, so cookies should store and check the
protocol, additionally to the path and domain.
* Fixes #10195.
2013-12-03 16:42:54 +01:00
Adrien Destugues
dc6d2ef664 HttpRequest: simplify and optimize receiving loop
* Do not start with a ridiculously small buffer for socket reads.
Sockets return data they have available, instead of trying to fill as
much of the buffer as possible. In some cases a single Ethernet frame
can hold a complete request.
* Remove some looping and try parsing all the request in sequence each
time we receive some bytes.
* Avoid reallocating a temporary buffer each time we read some data from
the socket. Instead, allocate it once, and grow it as needed. Since
servers usually send chunks of equal size, we should get away with one
reallocation on the first chunk.
2013-12-03 09:46:59 +01:00
Jérôme Duval
754bbf4866 libnetapi: second pass of style cleanup
* remarks from Axel
2013-11-26 23:36:42 +01:00
Adrien Destugues
509755e136 HttpRequest: remove fOutputBuffer
We can send the data directly to the output socket instead of copying it
into a BString first, at the cost of very slightly less information in
debug output.
2013-11-26 10:21:57 +01:00
Jérôme Duval
97ddf9019d libnetapi: style cleanup 2013-11-25 18:29:06 +01:00
Ingo Weinhold
ed9f4719f7 Fix FIONREAD related issues
* Network stack socket module: socket_control(): The FIONREAD argument
  is int, not ssize_t.
* Net kit: getsockopt(): R5_SO_FIONREAD: Fix ioctl() argument. Was
  taking a pointer of what already was a pointer to the buffer.
* libedit: el_gets(): The FIONREAD argument is int, not long.
2013-11-25 16:07:59 +01:00
Adrien Destugues
4192f44dc4 Make sure we never give a NULL context to requests.
Use a default context instead. This allows apps without a context
management to still have cookies and HTTP digest authentication (without
persistence to disk).

First part of fix to #10239 (it also needs changes in WebKit).
2013-11-25 12:04:55 +01:00
Michael Lotz
dcc56bf748 BNetEndpoint: Fix socket leak and reduce Accept() overhead.
When using the copy constructor of BNetEndpoint the socket of the
original endpoint gets dup'ed. The Accept() method later directly reset
the fSocket member of the newly created BNetEndpoint to the socket
returned by accept(). The socket dup'ed by the copy constructor was
therefore leaked.

Of course dup'ing the socket and copying the local and remote addresses
is superfluous in the accept case, as these members all get set to new
values. To reduce that overhead there is now a new private constructor
that directly gets the final socket and remote and local address.
2013-11-24 22:36:29 +01:00
Adrien Destugues
5c4dd6047b Remove debug print. 2013-11-20 22:39:14 +01:00
Stefano Ceccherini
0bc615438a Style fixes.
Style fixes pointed out by Axel. I'm rusty, and it shows.
Hope I got it right.
Also moved get_route() into BPrivate.
2013-11-18 20:01:35 +01:00
Stefano Ceccherini
41d4206692 Added family parameter to the GetRoutes() API.
Moved common code to a private file.
2013-11-18 10:13:26 +01:00
Adrien Destugues
ba3f67bfb4 FileRequest: make sure we're dealing with a file.
Trying to Read from a directory results in an error code, but we also
missed that because an unsigned variable was used to store the result.

Fixes #10210.
2013-11-18 09:53:04 +01:00
Stefano Ceccherini
905f910e53 Network route API: Second try (WIP).
Implement BNetworkRoster::GetRoutes() and BNetworkInterface::GetRoutes().
Also implement BNetworkInterface::GetDefaultGateway().
There is code duplication at the moment, and the api only supports IPV4.
2013-11-16 13:29:32 +01:00
Stefano Ceccherini
0074cea398 Implement BNetworkRoster::GetNextRoute()
Implement BNetworkRoster::GetNextRoute() and used it in Network preflet.
2013-11-15 21:59:28 +01:00
Adrien Destugues
cb7df3b1da Update webkit and cmake packages
* Some changes required in WebPositive to store the cookies on disk
2013-11-15 18:39:07 +01:00
Adrien Destugues
564e256649 Various fixes to Services Kit
* Remove useless dummy protocol loop in UrlRequest
 * Stop HTTP requests before deleting the socket and other things the
loop may still be using
 * Deletion of items from the authentication map wasn't working
 * Remove some debug traces
2013-11-15 16:32:18 +01:00
John Scipione
c2c1ce1dc5 Style fixes to HttpRequest 2013-11-04 20:16:26 -05:00
John Scipione
f1e63b05cb Style fixes to HttpForm 2013-11-04 20:16:05 -05:00
Adrien Destugues
9ce2f7e386 Improve HTTP authentication support.
The authentication state is stored (in a hash map, using the domain+path
as a key) in the UrlContext class. It can then be reused for multiple
requests to the same place. We also lookup stored authentications for
parent directories and stop at the first we find.

Authentication state is not stored on disk (unlike cookies), and there
can only be one for each domain+path.
2013-10-28 17:29:20 +01:00
Adrien Destugues
b7617ddd68 Network Cookie Jar: implement assignment operator.
This change is needed for implementing cookie persistence in Web+ using
the network kit backend.

The current implementation requires the user to unarchive the cookie
jar, then hand it over to the BUrlContext which will copy it to its own
field. This makes the code simpler, but maybe doing a complete copy
(with all the cookies) is an heavy operation and could be avoided.
2013-10-28 17:29:19 +01:00
Adrien Destugues
c52c444c27 Add file: protocol handler. 2013-10-24 17:41:03 +02:00
Adrien Destugues
f6782201f0 Move UrlResult to HttpResult
* Remove the fRawData field, as handling it is too complicated (it's
not easy to have proper copy semantics on a BDataIO) and it's not used
anyway, as the listener DataReceived call is enough to get the data and
handle it.
 * All the remaining fields are HTTP-only, so rename the class to
HttpResult and attach it to HttpRequest instead of UrlRequest.
2013-10-24 17:41:02 +02:00
Adrien Destugues
b3d13a000c Network Kit: Coverity scan review and fixes
CID 1108353, 1108335: memory leak.
CID 610473: unused variable.
CID 1108446, 1108433, 1108432, 1108419, 1108400, 991710, 991713, 991712,
	610098, 610097, 610096, 610095: uninitialized field
CID 1108421: unused field

Change the ownership of the result for Url/HttpRequests. The request now
owns its result and you either access it by reference while the request
is live, or copy it to keep it after the request destruction. To help
with that, get BUrlResult copy constructor and assignment operator to
work.

Performance issue: copying the BUrlResult also copies the underlying
BMallocIO data. This should be shared between the BUrlResult objects to
make the copy lighter. The case of BUrlSynchronousRequest is now
particularly inefficient, with at least 2 copies needed to get at the
result.
2013-10-21 09:21:00 +02:00
Adrien Destugues
25b034e99c HttpRequest: docs and memory management fixes
* Now takes ownership of headers, form data and input data
 * Split Set* and Adopt* methods to help with proper use of this (Set
does a copy)
 * Write documentation.
2013-10-17 14:24:20 +02:00
Adrien Destugues
ced0e0be04 BUrl: use a regex to parse URLs
* The RFC provide a regular expression for URI parsing, so just use it.
 * Allows parsing URIs with missing components (no scheme or authority)
 * This allows to parse relative URLs as expected
 * Can also handle things such as data: or mailto:
 * Also more fixes to handling of incomplete URIs, some flags weren't
always set to the right values.

This gets Windows Live Mail (or is it called Outlook?) working, with
some other fixes on WebKit side.
2013-10-16 21:01:43 +02:00
Adrien Destugues
f289aa4c74 BNetworkCookie: Allow cookies without a path
* They will be valid for the whole domain
 * login.live.com cookie test now works
2013-10-16 13:51:55 +02:00
Adrien Destugues
400153ebf5 BUrl: parse URLs using a regular expression.
* RFC3986 provides the regexp to parse URIs properly
 * Code is simpler and safer
 * Avoids an infinite loop when trying to parse some data: URIs
2013-10-16 13:51:54 +02:00
Adrien Destugues
5faf4d55b7 Fix max-age setting
* It would not work for cookies set to expire tomorrow or later, since
setting the time in a BDateTime does not overflow to the date.
 * The BDateTime API could be improved to make this look nicer.
2013-10-16 13:51:52 +02:00
Adrien Destugues
7895042a8a Service Kit: Fix behavior in release mode
* Code put inside an ASSERT will not be executed at all in release mode.
 * In release builds, don't print any messages to the standard output.
2013-10-15 16:48:46 +02:00
Adrien Destugues
bb1d0adcd1 BUrl: fix handling of @ character
* @ is a separator (between user:password and host) only if there are
no slashes before it
 * All slashes in user and password should be urlencoded (as well as any
@ and :)
 * On the other hand, it's possible to have @ as part of an URL path or
query. An example is Google Maps.

Gets Google Maps working.
2013-10-15 14:45:16 +02:00
Adrien Destugues
7696f7dd54 HttpRequest: allow custom http methods
* The W3C XmlHttpRequest testsuite likes to use "CHICKEN" as a method.
 * Also add constants for all specified methods in HTTP 1.1.
2013-10-15 14:43:09 +02:00
Adrien Destugues
f6f14c5d1c Make BUrlProtocolAsynchronousListener inherit BUrlProtocolListener
* With so long class names, there's no way I'm going to follow the 64
char limit on commit headlines.
 * The class share the same API, so having them separate is not very
useful.
 * This makes it possible to use the same listener in either synchronous
or asycnhronous mode (or both, for different requests)
2013-10-15 10:16:33 +02:00
Adrien Destugues
c9d31eeed6 More cookie fixes
* Add some error handling in NetworkCookie and don't add broken cookies
(or should I say crumbs?) to the cookie jar
 * More control on the path and domain, as well as the expiration time

We now pass Opera cookie testsuite functionality tests, as well as some
of the negative tests (we even do better than curl). Not going further
right now as this works well enough for positive cases and most
security/privacy issues are fixed (cross domain and cross path cookie
setting or spying).
2013-10-14 15:21:51 +02:00
Adrien Destugues
b7d85d666a fix build. 2013-10-11 22:13:04 +02:00
Adrien Destugues
f9d987ae68 HttpRequest: put cookies in a single header entry
* Http spec says headers can be split when they are comma separated
 * However, cookies are semicolon separated, so it is not acceptable to
split them.
 * We will want to implement some way to limit the cookie header entry
size, as servers have a limit on what they can accept (usually around 4K
characters). The RFC also says we don't need to remember more than 20
cookies per domain.
2013-10-11 21:44:08 +02:00
Adrien Destugues
eab89314ce NetworkCookie: fix date validity check
* January 1st 1970 is a perfectly valid expiration date for a cookie,
and shouldn't magically turn it into a session cookie.
2013-10-11 08:32:28 +02:00
Adrien Destugues
185471c844 HttpRequest: follow 302 redirects by default. 2013-10-11 08:32:27 +02:00
Adrien Destugues
a5ac24f00c BUrl: add a Redirect method
* This takes a relative path as a parameter, and modifies the object to
point to the given location.
 * '..' is not handled yet, and will be sent as-is to the server.
 * Makes it possible to follow more types of 302 redirects

In particular, I can now run the tests from Opera's testsuite
(testsuite.opera.com), which shows I have more work to do on cookie
handling.
2013-10-11 08:32:25 +02:00
Adrien Destugues
0e030f22e1 Allow cookies domain to not start with a dot
* The dot was mandatory in older RFCs, but the new RFC6265 disallow it.
 * Both schemes are used around the web, so we allow them both.

It's possible to login to mail.google.com again.
2013-10-09 15:50:33 +02:00
Adrien Destugues
8ca6eeb77c HttpRequest: missing fields initializations
* Some fields weren't initialized, leading to random crashes later on
 * Remove the enum that was used for protocol options
 * Use a single field to track the request state, instead of separate
booleans.
2013-10-09 15:46:10 +02:00
Adrien Destugues
a5826aafb0 Don't send a chunked transfer terminator for non-chunked transfers.
* Fixes oversight from previous change.
 * Thanks hamishm for watching !
2013-10-09 12:12:43 +02:00
Adrien Destugues
780967d8ac Cleanup and fix cookies handling
* The cookie jar iterator now use a BObjectList instead of a BList
 * Add a convenience method to the cookie jar to add a cookie by BUrl
and raw cookie string.
 * Remove some methods in BNetworkCookie that could lead to invalid
cookies (cross-domain or with no domain at all).
 * Make the cookie parsing able to report errors
 * Fix off-by-one error in domain cookies validation.
2013-10-09 12:08:46 +02:00
Adrien Destugues
afd547b368 Refactor UrlRequest/UrlProtocol in the Service Kit
* Remove the BUrlRequest class, which was only delegating work to
BUrlProtocol and subclasses
 * Rename BUrlProtocol to BUrlRequest, and BUrlRequestHttp to BHttpRequest
 * Creating a request is now done through the BUrlProtocolRoster. For
now there is just a static MakeRequest method, this will be completed
when we get to actually allowing add-ons to provide different request
handlers.

This allows cleanup of the API for requests:
 * Remove the universal SetOption method with constants, and have
dedicated setters for each protocol option.
 * Setters can now have multiple parameters, for example you can give
BHTTPRequest a BDataIO and a known size
 * In this case, the BHttpRequest will not use HTTP chunked transfers,
which were always used before and made most servers unhappy (tested and
failed with lighttpd, google accounts and github).
2013-10-08 11:42:05 +02:00
Adrien Destugues
49e7165f9d Use ssize_t to allow returning a negative error code 2013-10-04 16:57:02 +02:00
Ingo Weinhold
38fa81bf8f Remove B_COMMON*_DIRECTORY and kCommon*Directory constants
* This does intentionally break source compatibility, so that a review
  of concerned code is forced.
* Binary compatibility should be maintained in most cases. The values
  of the constants for the writable directories are now used for the
  writable system directories. The values for the non-writable
  directories are mapped to "/boot/system/data/empty/...", an empty or
  non-existent directory, so that they will simply be skipped in search
  paths. Only code that explicitly expects to find something in a
  B_COMMON_* directory, will fail.
2013-10-04 02:30:30 +02:00
Ingo Weinhold
4b7e219688 Remove /boot/common for good
* Remove support for the "common" installation location from packagefs,
  package kit, package daemon, package managers.
* Rename the B_COMMON_*_DIRECTORY constants referring to writable
  directories to B_SYSTEM_*_DIRECTORY.
* Remove/adjust the use of various B_COMMON_*_DIRECTORY constants.
  I'm sure some occurrence still remain. They can be adjusted when the
  remaining B_COMMON_*_DIRECTORY constants are removed.
2013-10-03 21:52:25 +02:00
Adrien Destugues
bf9b153fcc Force AF_INET when resolving addresses
* The default is to use IPv6 addresses, but these don't quite work yet
in Haiku.
 * Also, some debug messages improvements and fix a crash when the
	payload has % inside it (parsing it as a printf string isn't such a
	good idea)
2013-10-03 17:09:00 +02:00
Ingo Weinhold
9f81ca838c Merge branch 'package-management'
Conflicts:
	src/preferences/network/Jamfile
2013-09-27 02:01:12 +02:00
Axel Dörfler
a3c0790695 BNetworkAddress: accept NULL link address strings. 2013-09-27 01:02:00 +02:00
Ingo Weinhold
cf70d345b2 Merge remote-tracking branch 'haiku/master' into package-management
This reverts 8f7f28a7c3 (OpenGL: Upgrade
to
Mesa 9.2).

Conflicts:
	build/jam/BuildFeatures
	build/jam/HaikuImage
	build/jam/OptionalPackages
	build/scripts/build_cross_tools_gcc4
	src/add-ons/opengl/swpipe/Jamfile
	src/apps/diskusage/Jamfile
	src/kits/tracker/ContainerWindow.cpp
	src/kits/tracker/DeskWindow.cpp
	src/kits/tracker/Jamfile
2013-09-13 01:02:28 +02:00
Adrien Destugues
a8dd17c9b9 UrlProtocolHttp: parse received cookies
* We didn't do anything with cookies received from the server, they are
now automatically added to the cookie jar.
 * Also make sure the UrlContext (which holds the cookie jar) is
forwarded from UrlRequest to UrlProtocol when it gets set.

this gets cookies working in Service Kit-based WebKit.
2013-09-01 19:40:57 +02:00
Adrien Destugues
2ec188b903 Fix thread safety issue in chunked http transfers.
* The use of a static variable for storing the chunk size made it shared between all instances of BUrlProtoclHttp.
* Inline the function at the single place where it is used, and allocate the variable on the stack instead.

The whole receiving loop should be split into chunked and non-chunked variants to improve code readability.
2013-08-27 20:36:29 +02:00
Ingo Weinhold
225b638263 Support building most system libraries for secondary arch
Also adjust the HaikuImageGet[Private]SystemLibs rules to support to
return the library targets matching the current architecture.
2013-08-06 00:45:22 +02:00
Ingo Weinhold
7bd562abc9 lib{network,package,shared,agg,icon}: secondary arch support 2013-08-05 06:41:53 +02:00
Ingo Weinhold
7e78b434f4 Merge remote-tracking branch 'haiku/master' into package-management
Conflicts:
	build/jam/HaikuImage
	build/jam/OptionalPackageDependencies
	build/jam/OptionalPackages
	build/scripts/build_cross_tools_gcc4
	src/add-ons/translators/icns/Jamfile
	src/add-ons/translators/jpeg/Jamfile
2013-07-08 14:01:00 +02:00
Ingo Weinhold
ebb78dd9b7 Update openssl package
Also use the new build feature rules
2013-06-13 16:43:40 +02:00
Philippe Houdoin
89e83cf613 Style cleanup and fix a possible endless loop 2013-05-15 19:46:30 +02:00