Giter Site home page Giter Site logo

myconsciousness / sweet-cookie-jar Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 4.0 31 KB

A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

Home Page: https://pub.dev/packages/sweet_cookie_jar

License: BSD 3-Clause "New" or "Revised" License

Dart 100.00%
dart flutter cookie cookiejar library pubdev cookie-management

sweet-cookie-jar's Introduction

sweet_cookie_jar

A most easily usable cookie management library in Dart!

pub package codecov Analyzer Test

1. About

SweetCookieJar is an open-sourced Dart library.
With SweetCookieJar, you can easily manage cookie on your application.

SweetCookieJar is a library that extends the functionality of the official Cookie class. It also works with Responses in the http package, and even if multiple set-cookie are set in the response header, which is a weak point in the http package, SweetCookieJar can manage these cookie information very easily!

No more difficult implementation is needed to handle multiple set-cookie set in response header in Dart. Just pass the Response to the constructor of SweetCookieJar!

1.1. Introduction

1.1.1. Install Library

With Dart:

 dart pub add sweet_cookie_jar

With Flutter:

 flutter pub add sweet_cookie_jar

1.1.2. Import It

import 'package:sweet_cookie_jar/sweet_cookie_jar.dart';

1.1.3. Use SweetCookieJar

import 'package:sweet_cookie_jar/sweet_cookie_jar.dart';

void main() {
    // The cookie set in the response header
    // will be extracted by the constructor process.
    final cookieJar = SweetCookieJar.from(response: response);

    if (cookieJar.isEmpty) {
        // It means that there is no cookie information
        // in the response header.
        return;
    }

    // You can find cookie by name easily.
    final cookie = cookieJar.find(name: 'AWSALB');
    print(cookie.name);
    print(cookie.value);

    // Also you can get cookie as JSON format.
    print(cookie.toJson());

    if (cookie.isExpired) {
        // Do something when cookie is expired.
        return;
    }
}

1.2. License

Copyright (c) 2021, Kato Shinya. All rights reserved.
Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.

1.3. More Information

SweetCookieJar was designed and implemented by Kato Shinya.

sweet-cookie-jar's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sweet-cookie-jar's Issues

Can't use with http: 1.0.0 version

Hi,

Thanks for this Sweet Cookie Jar package, I'm trying to use this package with http package version 1.0.0.

But I'm facing the below version solving issue

Because sweet_cookie_jar 1.1.0 depends on http ^0.13.4 and no versions of sweet_cookie_jar match >1.1.0 <2.0.0, sweet_cookie_jar ^1.1.0 requires http ^0.13.4.
So, because team_appcommon depends on both http ^1.0.0 and sweet_cookie_jar ^1.1.0, version solving failed.

Can you release new version for Sweet Cookie Jar package?

Exception thrown when cookie values contain invalid characters

Hi, I'm encountering an exception on the SweetCookieJar.from() function when set-cookie header contains invalid characters.

// r.headers['set-cookie'] contains invalid characters in the cookie sent by server 
var cookieBin = SweetCookieJar.from(response: r); 

My current workaround is to perform string manipulation on the cookie string to replace those invalid characters..

merge two `SweetCookieJar`s

I'm working with https://github.com/jossef/requests which does http requests with seamless cookies in between them. I would like to use this package instead of a custom made CookieJar, but SweetCookieJar is lacking a way to edit the cookies inside it.

So I would like a way to alter the cookies inside a SweetCookieJar (and also a way to merge 2 SweetCookieJars).

This way a CookieJar can be altered with some newly set cookies by the server, and then resent on a new request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.