<commit_before>var http    = require('http');
var util = require('util');
var url     = require('url');
var fs      = require('fs');
var uuid = require('node-uuid');

function redirect(response, url) {
                response.statusCode = 302;
                response.setHeader("Location", url);
                response.end();
}

function createServer(config, login_url) {
    http_server = http.createServer(function (request, response) {
        var request_url = url.parse(request.url, true);
        console.log(request_url.pathname);
        switch(request_url.pathname){
            case '/auth':
                authorization_code = url.parse(request.url, true).query.code;
                uuid = url.parse(request.url, true).query.state;
                http_server.emit('auth', authorization_code, uuid);
                redirect(response, config.redirect_url);
                break;
            case '/login':
                response.setHeader("Content-Type", 'application/json');
                response.end(JSON.stringify({"login_url":login_url, "state":uuid.v4()}));
                break;
            default :
                redirect(response, config.redirect_url);
                break;
        };
    });

    http_server.listen(config.port);

    return http_server
}

exports.createServer = createServer;
<commit_msg>http.js: bug fix, /login works now<commit_after>var http    = require('http');
var util = require('util');
var url     = require('url');
var fs      = require('fs');
var uuid = require('node-uuid');

function redirect(response, url) {
                response.statusCode = 302;
                response.setHeader("Location", url);
                response.end();
}

function createServer(config, login_url) {
    http_server = http.createServer(function (request, response) {
        var request_url = url.parse(request.url, true);
        switch(request_url.pathname){
            case '/auth':
                authorization_code = url.parse(request.url, true).query.code;
                var id = url.parse(request.url, true).query.state;
                http_server.emit('auth', authorization_code, id);
                redirect(response, config.redirect_url);
                break;
            case '/login':
                var id = uuid.v4();
                if(url.parse(request.url, true).query.callback) {
                    response.setHeader("Content-Type", 'text/javascript');
                    var data = url.parse(request.url, true).query.callback + "(" + JSON.stringify({"login_url":login_url, "state": id}) + ");";
                } else {
                    response.setHeader("Content-Type", 'text/plain');
                    var data = login_url + "&state=" + id;
                };
                response.end(data);
                break;
            default :
                redirect(response, config.redirect_url);
                break;
        };
    });

    http_server.listen(config.port);

    return http_server
}

exports.createServer = createServer;

{'fraction_non_alphanumeric': 0.13085036255767962, 'fraction_numerical': 0.0026367831245880024, 'mean_word_length': 1.9696673189823874, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1279229', 'n_tokens_mistral': 836, 'n_tokens_neox': 795, 'n_words': 156}