[haiku-commits] Re: haiku: hrev45250 - src/kits/network/libnetapi headers/os/net

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 08 Feb 2013 01:14:10 +0100

On 02/08/2013 12:02 AM, hamishm53@xxxxxxxxx wrote:
    * Use a public domain MD5 implementation when the OpenSSL one is not 
available

The POP3 add-on already sports its own MD5 implementation. Maybe we can remove that one now? It doesn't make sense to have several of those in our tree :-)
Maybe moving it to libshared.a would then also make sense.

+       md5.c

Why is this being compiled in unconditionally? Shouldn't it only be part of the build if there is no OpenSSL?

+BUrlProtocolHttp::BUrlProtocolHttp(BUrl& url, bool ssl,
+               BUrlProtocolListener* listener, BUrlContext* context,
+               BUrlResult* result)
        :
        BUrlProtocol(url, listener, context, result, "BUrlProtocol.HTTP", 
"HTTP"),
        fRequestMethod(B_HTTP_GET),
        fHttpVersion(B_HTTP_11)
  {
        _ResetOptions();
+       if (ssl)
+               fSocket = new BSecureSocket();
+       else
+               fSocket = new BSocket();
+
+}

Stray blank line.

@@ -368,7 +375,7 @@ BUrlProtocolHttp::_MakeRequest()
        
        _EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT, "Sending request (size=%d)",
                fOutputBuffer.Length());
-       fSocket.Send(fOutputBuffer.String(), fOutputBuffer.Length());
+       fSocket->Write(fOutputBuffer.String(), fOutputBuffer.Length());

I know it's not your code, but: suspiciously little error checking... (here and at other places)

+++ b/src/kits/network/libnetapi/UrlRequest.cpp
@@ -136,7 +136,15 @@ BUrlRequest::Identify()
        fUrlProtocol = NULL;
        
        if (fUrl.Protocol() == "http") {
-               fUrlProtocol = new(std::nothrow) BUrlProtocolHttp(fUrl, fListener, 
fContext, &fResult);
+               fUrlProtocol = new(std::nothrow) BUrlProtocolHttp(fUrl, false,
+                                                                     
fListener, fContext,
+                                                                                   
                              &fResult);
+               fReady = true;
+               return B_OK;
+       } else if (fUrl.Protocol() == "https") {
+               fUrlProtocol = new(std::nothrow) BUrlProtocolHttp(fUrl, true,
+                                                                     
fListener, fContext,
+                                                                                   
                              &fResult);

The arguments should only be indented a single tab further!

  class BUrlProtocolHttp : public BUrlProtocol {
  public:
                                                                
BUrlProtocolHttp(BUrl& url, bool ssl = false,
+                                                                       const char 
*protocolName = "HTTP",

Change in asterisk style.

  BUrlProtocolHttp::BUrlProtocolHttp(BUrl& url, bool ssl,
-               BUrlProtocolListener* listener, BUrlContext* context,
-               BUrlResult* result)
+               const char *protocolName, BUrlProtocolListener* listener,

Same here.

+       else {
+               if (fSSL)
+                       fRemoteAddr = BNetworkAddress(fUrl.Host(), 443);
+               else
+                       fRemoteAddr = BNetworkAddress(fUrl.Host(), 80);
+       }
+                               

Whitespace at the end of line.
The above could be written less wordy using ?:

Bye,
   Axel.


Other related posts: