Bug 177373 - [Curl] Refactor and improve methods in the CurlHandle
Summary: [Curl] Refactor and improve methods in the CurlHandle
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Basuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-22 11:46 PDT by Basuke Suzuki
Modified: 2017-09-27 12:17 PDT (History)
8 users (show)

See Also:


Attachments
patch (15.88 KB, patch)
2017-09-25 11:52 PDT, Basuke Suzuki
achristensen: review-
achristensen: commit-queue-
Details | Formatted Diff | Diff
fix (16.10 KB, patch)
2017-09-25 12:43 PDT, Basuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Basuke Suzuki 2017-09-22 11:46:46 PDT
Cleanup method name, consistent naming, remove unused feature, better enum naming, etc.
Comment 1 Basuke Suzuki 2017-09-25 11:52:31 PDT
Created attachment 321714 [details]
patch
Comment 2 Alex Christensen 2017-09-25 12:14:14 PDT
Comment on attachment 321714 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=321714&action=review

> Source/WebCore/platform/network/curl/CurlContext.cpp:263
> +        m_handle = nullptr;

It's probably not necessary to set m_handle to nullptr in the destructor.

> Source/WebCore/platform/network/curl/CurlContext.cpp:345
> +void CurlHandle::removeRequestHeader(const String& name)
> +{
> +    // Add a header with no content, the internally used header will get disabled. 
> +    String header(name);
> +    header.append(":");
> +
>      appendRequestHeader(header);

This is very confusing.  Are we removing or appending?  We should definitely call it something else.

> Source/WebCore/platform/network/curl/CurlContext.cpp:354
> +void CurlHandle::appendRequestHeader(const String& header, bool appendOnly)
>  {
>      m_requestHeaders.append(header);
> +
> +    if (!appendOnly)
> +        enableRequestHeaders();
>  }

I think adding this bool indicates that we've got the responsibilities of these functions all wrong.
Comment 3 Basuke Suzuki 2017-09-25 12:43:54 PDT
Created attachment 321723 [details]
fix
Comment 4 Basuke Suzuki 2017-09-25 12:44:06 PDT
Thank you. I've fixed.
Comment 5 Basuke Suzuki 2017-09-25 13:27:05 PDT
> > Source/WebCore/platform/network/curl/CurlContext.cpp:345
> > +void CurlHandle::removeRequestHeader(const String& name)
> > +{
> > +    // Add a header with no content, the internally used header will get disabled. 
> > +    String header(name);
> > +    header.append(":");
> > +
> >      appendRequestHeader(header);
> 
> This is very confusing.  Are we removing or appending?  We should definitely
> call it something else.

This is the libcurl's spec. If we need to delete the pre appended header including the default prepared one, we need to append empty value header to the list. The original code has used that behavior directly, so we've added a meaningful method and hide the detail inside.
Comment 6 Basuke Suzuki 2017-09-25 13:28:47 PDT
(In reply to Alex Christensen from comment #2)
> Comment on attachment 321714 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=321714&action=review
> 
> > Source/WebCore/platform/network/curl/CurlContext.cpp:263
> > +        m_handle = nullptr;
> 
> It's probably not necessary to set m_handle to nullptr in the destructor.

removed. Also removed from other class's destructors.


> > Source/WebCore/platform/network/curl/CurlContext.cpp:354
> > +void CurlHandle::appendRequestHeader(const String& header, bool appendOnly)
> >  {
> >      m_requestHeaders.append(header);
> > +
> > +    if (!appendOnly)
> > +        enableRequestHeaders();
> >  }
> 
> I think adding this bool indicates that we've got the responsibilities of
> these functions all wrong.

removed that flag argument and handle the situation internally.
Comment 7 WebKit Commit Bot 2017-09-25 16:24:48 PDT
Comment on attachment 321723 [details]
fix

Clearing flags on attachment: 321723

Committed r222479: <http://trac.webkit.org/changeset/222479>
Comment 8 WebKit Commit Bot 2017-09-25 16:24:53 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2017-09-27 12:17:32 PDT
<rdar://problem/34692963>