Code Monkey home page Code Monkey logo

http-string-parser's Issues

Typings

It'd be nice if it had Typescript typings. Here's a start in case anyone else needs them:

declare module 'http-string-parser' {
  export interface HttpStringParserResult {
    protocolVersion: string
    statusCode: string
    statusMessage: string
    headers: { [key: string]: string }
    body: string
  }
  function parseRequest(requestString: string): HttpStringParserResult

  function parseRequestLine(requestLine: string): HttpStringParserResult

  function parseResponse(responseString: string): HttpStringParserResult

  function parseStatusLine(statusLine: string): HttpStringParserResult

  function parseHeaders(headersLinesArray: string[]): HttpStringParserResult
}

Missing headers with same names (like Set-Cookie)

Parsing this response

HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Security-Policy: script-src 'self'
Strict-Transport-Security: max-age=31536000
Set-Cookie: JSESSIONID=1AF9A42DC89C0CD2620ECE5449074DF1.PPM1-1; Path=/itg/; HttpOnly
Set-Cookie: JSESSIONID=1AF9A42DC89C0CD2620ECE5449074DF1.PPM1-1; path=/itg; HTTPOnly
Accept-Language: ru_RU
Cache-Control: no-cache, post-check=0, pre-check=0
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Wed, 25 Oct 2017 12:57:35 GMT
Server: 

produce result without second Set-Cookie header

{
     'X-Frame-Options': 'SAMEORIGIN',
     'X-XSS-Protection': '1; mode=block',
     'X-Content-Security-Policy': 'script-src \'self\'',
     'Strict-Transport-Security': 'max-age=31536000',
     'Set-Cookie': 'JSESSIONID=1AF9A42DC89C0CD2620ECE5449074DF1.PPM1-1; path=/itg; HTTPOnly',
     'Accept-Language': 'ru_RU',
     'Cache-Control': 'no-cache, post-check=0, pre-check=0',
     'Content-Type': 'text/html;charset=UTF-8',
     'Transfer-Encoding': 'chunked',
     Date: 'Wed, 25 Oct 2017 12:57:35 GMT',
     Server: ''
}

Fails parsing request

Request

HTTP/1.1 200 OK
Date: Thu, 11 Jun 2015 07:56:03 GMT
Server: Apache-Coyote/1.1
X-Powered-By: Servlet/3.0; JBossAS-6
Access-Control-Allow-Origin: *
Content-Type: text/xml;charset=UTF-8
Vary: Accept-Encoding
Content-Length: 704
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Cache-Control: no-cache

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns2:getMobileDevicesForRegisteredUserResponse xmlns:ns2="http://registration.xxx/">
            <mobileDevice>
                <id>7150</id>
                <name>Telefon1</name>
                <serialNumber>1234567890</serialNumber>
            </mobileDevice>
            <mobileDevice>
                <id>7151</id>
                <name>Telefon2</name>
                <serialNumber>12345678901</serialNumber>
            </mobileDevice>
            <mobileDevice>
                <id>7152</id>
                <name>Telefon3</name>
                <serialNumber>21D81939-3026-4CD4-8D41-50A115C65663</serialNumber>
            </mobileDevice>
        </ns2:getMobileDevicesForRegisteredUserResponse>
    </soap:Body>
</soap:Envelope>

Request parsed

{
  protocolVersion: undefined,
  statusCode: undefined,
  statusMessage: undefined,
  headers: {},
  body: ''
}

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.